這是處理:我有一個表單,需要一段時間才能提交,因爲我在等待一些第三方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