1
緩衝區數組我使用$.when
在其他邏輯之前運行2個函數。現在,在幾種情況下,我需要在執行相同的邏輯之前運行一組不同的函數,所以我想將一組函數傳遞給$.when
,但無法運行。使用jQuery.when()
喜歡的東西:
function funcA(){
console.log("funcA");
}
function funcB(){
console.log("funcB")
}
var funcArr = [funcA, funcB];
$.when(funcArr).then(function(){
console.log("DONE!");
});
但是,這並不工作,並寫入控制檯的唯一事情就是「DONE!」。 我閱讀下列How do you work with an array of jQuery Deferreds?,但下面的行爲是一樣的:
$.when.apply($, funcArr).then(function(){
console.log("DONE!")
});
有什麼不對呢? 謝謝。
很好,感謝您的迅速回復! – Haji 2013-02-18 07:34:49