点击提交时什么都没有发生,因为在你的 js 中你正在调用它
$(".comment_form, .contact_form").submit(function(event) 并且您使用了 event.preventDefault(); ,因此该表单不显示默认行为。检查控制台你的js有错误。它说
TypeError: $(...).block 不是函数。
您需要先修复这些错误。
这是处理表单的 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");
}
}