沒有任何反應,當你點擊你的JS,因爲提交你調用這個
$(".comment_form, .contact_form").submit(function(event)
,你已經使用event.preventDefault();
,因此表單不顯示默認的行爲。檢查控制檯,你有一個錯誤js。它說
TypeError:$(...)。塊不是函數。
您需要先解決這些錯誤。
這是處理您的表單的js。
if($(".contact_form").length)
$(".contact_form")[0].reset();
if($(".comment_form").length)
$(".comment_form")[0].reset();
$(".comment_form, .contact_form").submit(function(event){
event.preventDefault();
var data = $(this).serializeArray();
var id = $(this).attr("id");
$("#"+id+" .block").block({
message: false,
overlayCSS: {
opacity:'0.3',
"backgroundColor": "#FFF"
}
});
$.ajax({
url: config.ajaxurl,
data: data,
type: "post",
dataType: "json",
success: function(json){
//$("#"+id+" [name='submit'], #"+id+" [name='name'], #"+id+" [name='contact_name'], #"+id+" [name='telephone'], #"+id+" [name='email'], #"+id+" [name='products']").qtip('destroy');
if(typeof(json.isOk)!="undefined" && json.isOk)
{
if(typeof(json.submit_message)!="undefined" && json.submit_message!="")
{
$("#"+id+" [name='submit']").qtip(
{
style: {
classes: 'ui-tooltip-success'
},
content: {
text: json.submit_message
},
position: {
my: "right center",
at: "left center"
}
}).qtip('show');
//close tooltip after 5 sec
/*setTimeout(function(){
$("#"+id+" [name='submit']").qtip("api").hide();
}, 5000);*/
if(id=="comment_form" && typeof(json.html)!="undefined")
{
$(".comments").html(json.html);
$("#comment_form [name='comment_parent_id']").val(0);
if(typeof(json.comment_id)!="undefined")
{
var offset = $("#comment-" + json.comment_id).offset();
$("html, body").animate({scrollTop: offset.top-10}, 400);
if(typeof(json.change_url)!="undefined" && $.param.fragment()!=json.change_url.replace("#", ""))
$("#comment_form [name='prevent_scroll']").val(1);
}
if(typeof(json.change_url)!="undefined" && $.param.fragment()!=json.change_url.replace("#", ""))
$.bbq.pushState(json.change_url);
//window.location.href = json.change_url;
}
$("#"+id)[0].reset();
$("#cancel_comment").css("display", "none");
$(".contact_form [name='department']").val("");
$(".contact_form .tabs_box_navigation_selected>span").text("Select department");
}
}
這不太合適。這很好,做你的工作。如果您在章節或理解代碼時遇到問題,請詢問,而且人們會樂於幫助。不要只希望有人會爲你解決它。 –