簡體   English   中英

在承諾未決時執行延遲的回調

[英]Callback of deferred to be executed while promise is pending

在等待jQuery.Deferred的承諾時,如何配置要運行的代碼? 所以喜歡:

$.when(someAJAX).whatever(function() {
    // run this while the AJAX is loading
}).done(function() {
    // run this when it is done
});

我已經檢查了文檔 ,但什么都沒找到,但也許我錯過了一些東西( deferred.progress()在這里不起作用)。

我認為你想要的東西比你想做的要簡單得多。 相反,你可以這樣做:

$.when.apply($, arrayOfPromises).done(function() {
    // code here when ajax call is done
});
// this code will execute right after the ajax call was initiated
// put code here to set state while ajax is loading

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM