我有一個計算每個服務器性能的網站。其中一個要求是關於性能的中心局部頁面必須先完成加載才能在後臺執行另一個功能。當document.ready中的函數完成時執行js函數
該中心部分頁面使用ajax調用。他們在js文件的document.ready
被定義:
$(document).ready(function() {
// ajax call here
// another ajax call here
// third ajax call here
});
然後我想要的文件準備好內部的功能之後要執行的函數完成:
function functionA() {
// some codes here
});
我嘗試使用這樣的:
$.when(document).ready(function() {
}).done(functionA);
但我不能讓它運行..任何建議將很樂意讚賞。提前致謝!
你要執行的功能,當'document.ready'完成後,或當所有AJAX調用完成?兩件完全不同的事情。 – CodingIntrigue
@Rraham - 當ajax調用完成時。 – Gerald