jQuery:停止提交表单,执行脚本,继续提交表单? [英] jQuery: Stop submitting form, perform script, continue submitting form?
本文介绍了jQuery:停止提交表单,执行脚本,继续提交表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表单,当我提交他时,我执行多个脚本。这是我的代码:
I have a form, and when I submit him I execute multiple script. Here is my code:
$("#RequestCreateForm").submit(function (e) {
if ($("#RequestCreateForm").validate().checkForm() == false) { return; }
e.preventDefault();
//many scripts
//How to continue submitting?
}
是吗?可以在 //多个脚本
之后继续提交表单(使用 e.preventDefault();
停止)?
Is it possible to continue submitting the form (which is stopped with e.preventDefault();
) after //many scripts
?
谢谢
推荐答案
$("#RequestCreateForm").submit(function (e) {
if ($("#RequestCreateForm").validate().checkForm() === false) {
e.preventDefault();
//form was NOT ok - optionally add some error script in here
return false; //for old browsers
} else{
//form was OK - you can add some pre-send script in here
}
//$(this).submit();
//you don't have to submit manually if you didn't prevent the default event before
}
这篇关于jQuery:停止提交表单,执行脚本,继续提交表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文