本文介绍了使用e.preventDefault()后提交表单;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表单,我停止使用e.preventDefault()提交。 (我也试过返回false)。
I have a form that I am stopping from submitting with e.preventDefault(). (I've also tried return false).
我会在短暂的延迟后手动告诉表单提交,使用代码:
I would manually tell the form to submit after a short delay, using the code:
$('form').delay(2000).submit();
不幸的是,e.preventDefault()似乎禁止提交表单,即使它明确提交使用 submit()
function。
Unfortunately, e.preventDefault() seems to disable the form from submitting even if it explicitly submitted using the submit()
function.
我知道如何将这些意图结合起来?我想显示加载屏幕几秒钟。
Any idea how I can combine these intentions? I'd like to show a loading screen for a couple of seconds.
谢谢!
推荐答案
$("form").on('submit.blocker', function (e) {
setTimeout(function () {
$("form").off('submit.blocker').trigger('submit');
}, 2000);
e.preventDefault();
});
这篇关于使用e.preventDefault()后提交表单;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!