![](/img/trans.png)
[英]Why does my jQuery when().then() function trigger before the ajax request in when is done?
[英]jQuery when() function: does it fire before each single done?
我有一個bug,我懷疑是由於我對jQuery的不了解。 該場景在下面的剪輯中描述:
var towait = [];
towait.push($.get('someurl',function(data){ dosomething...}));
towait.push($.get('someurl',function(data){ dosomething...}));
....
towait.push($.get('someurl',function(data){ dosomething...}));
$.when(towait).done(function(){ dosomething else});
症狀是dosomething else
在dosomething調用之前執行(也許我錯了,我正在尋找一個bug)我的假設是正確的嗎? defferred似乎是在$ .get(...,function(){})執行之前加入的嗎? 如果是這樣,有一些方法可以改變這種行為?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.