我正在检查如何在$ .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
}
答案 0 :(得分:0)
我们可以使用参数
获取所有已解析的数据
$.when.apply(null, _promArr).then(function(){
***I need all data passed inside resolve here***
var resolvedData = JSON.parse(JSON.stringify(arguments));
}).always(function () {
console.log('all joint promises resolved always');
});