我使用这个jQuery功能发布形式:JQuery的POST功能
function SubmitForm(form, postaction) {
$(form).submit(function(event){
$('#LoadingDiv').show();
var data = $(this).serialize();
$.post(postaction, data)
.success(function(result){
console.log(result);
$('#LoadingDiv').hide();
$('.tabcontent').html(result);
$("html, body").animate({ scrollTop: 0 }, "slow");
})
.error(function(){
$('.tabcontent').html('Error Loading Page');
$("html, body").animate({ scrollTop: 0 }, "slow");
console.log('Error loading page');
})
return false;
});
}
我有喜欢的形式按钮:
<input type="submit" onclick="SubmitForm('#SearchHistoricInvoices', '/billing/viewhistoricinvoices.php');" value="Search" />
和表单标签:
<form method="post" id="SearchHistoricInvoices">
但是当使用上面的按钮提交表单时,它似乎刷新整个页面而不是实际提交表单
我检查了控制台,并没有错误
要绑定提交的onclick处理程序中处理。我猜,你的提交处理程序没有被解雇,所以FORM被引用 – 2015-02-10 20:05:51
从''中删除'type =“submit”'。这样做会启用您正在遇到的默认表单提交行为。 – Brett 2015-02-10 20:14:58