这是处理:我有一个表单,需要一段时间才能提交,因为我在等待一些第三方Web服务。所以我试图实现的是,点击提交按钮后,它被禁用,被分配一个特殊的类,如果提交表单超过5秒钟,则显示通知。setTimeOut AFTER jQuery表单提交
我想出了这一点:
$('#register_index_button').click(function(){
$(this).addClass('bt_button_loader');
$(this).val('Please wait');
$(this).attr('disabled', 'disabled');
$('#register_index_form').submit();
//it takes more than 5 seconds, display notice
setTimeout(function() {
$('#notice').html('Still waiting ...');
}, 5000);
});
一切工作正常,但超时功能。我猜是在我用jQuery提交表单之后,其他所有内容都被忽略了?
谢谢你的帮助!
你有没有尝试''提交'之前'setTimeout'? – JNF 2015-04-01 13:22:05
您必须将settimeout放置在窗体的事件onsubmit中。 – gaetanoM 2015-04-01 13:22:23
你的表格如何?它有Web服务网址吗?如果是,那么它会尝试重新加载另一个页面,这将是Web服务调用的结果。 – Vikash 2015-04-01 13:23:54