【发布时间】:2017-02-06 13:41:22
【问题描述】:
我正在检查如何在 $.when(null, promArr) 中获取所有已解析的数据
然后我得到了最后一个解析的数据。但我需要得到所有已解决的东西。
var _promArr = [],_prom = '';
_.each(uniqueAccountList, function(obj,idx){
_prom = getAccountDetails(obj.acctId);
_promArr.push(_prom);
});
$.when.apply(null, _promArr).then(function(){
***I need all data passed inside resolve here***
}).always(function () {
console.log('all joint promises resolved always');
});
function getAccountDetails(accid){
// perform ajaxcall and resolve or reject the promise
var _def = $.Deferred();
if (successs)
_def.resolve({accid:accid,status:1})
else if (fail.reason == 'Not found')
_def.resolve({accid:accid,status:0})
else
_def.reject();
return _def
}
【问题讨论】:
标签: jquery jquery-deferred resolve