我在我的代碼中有以下功能。這裏有一個簡化版本:有沒有什麼辦法可以在我的javascript中引入延遲?
$.ajax({
url: $form.attr('action'),
dataType: 'json',
type: 'POST',
data: $form.serializeArray(),
success: function (json, textStatus, XMLHttpRequest) {
// delay here
alert("hello");
}
有沒有什麼方法可以引入延遲。例如,延遲5秒進入上面的代碼?
請注意,如果可能,我需要將延遲字替換爲可延遲延遲的內容。
簽出setTimeout函數 - https://developer.mozilla.org/zh-CN/DOM/win dow.setTimeout – 2012-04-23 17:37:28