0
我想在Ajax回調響應之間延遲5秒。jquery Ajax響應延遲在回調函數響應之間
checkSucess = function() {
// Jquery Ajax with url,params and response
doPost('sucess.php',
'first=' + first,
function(response) {
var status = checkSucess(response,'X');
// I want to delay 5 seconds with this code before next checkSucess() function is called.
$('#SlideShow').html('<img id="SlideShows" src="images/loadingAnimation.gif">').delay(5000);
$('#button'+response).val("O");
$('#SlideShow').empty();
// End block.
var status = checkSucess(response,'O');
});
return response;
延遲不按照需要工作。圖像不顯示。如何解決它。
如果setTimeout的使用我想創建一個新的功能,並通過應對之道。但是它會給出一個錯誤「未定義響應」。我將如何解決這個問題? –
我覺得你很困惑,因爲你不能同步坐在JavaScript中5秒,阻止網頁運行。你需要定義一個你自己可以運行的函數。然後計劃它的運行時間,並在調度程序說是時間時調用它。 – xaxxon