JS / JQuery表单提交延迟? [英] JS /JQuery Form Submit Delay?
问题描述
我已经实现了这个'locksubmit'插件 http://blog.leenix.co.uk/2009/09/jquery-plugin-locksubmit-stop-submit.html ,它将按钮的显示状态更改为禁用。
然后我希望在发布到表单URL之前将表单延迟几秒钟。
I've implemented this 'locksubmit' plugin http://blog.leenix.co.uk/2009/09/jquery-plugin-locksubmit-stop-submit.html where it changes the display state of the button to disabled. I then want the form to be delayed by a few seconds before posting to the form URL.
我需要添加或修改以延迟用户点击提交按钮后形成发布?
What would I have to add in or modify to delay the form "post" once the user has clicked the submit button?
谢谢!
推荐答案
取消默认表单提交行为,并同时开始超时:
Cancel the default form submit behaviour, and start a timeout at the same time:
$('form').submit(function (e) {
var form = this;
e.preventDefault();
setTimeout(function () {
form.submit();
}, 1000); // in milliseconds
});
这应该与locksubmit插件兼容。
This should be compatible with the locksubmit plugin.
在此处观看演示: http://jsfiddle.net/7GJX6/
这篇关于JS / JQuery表单提交延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!