2017-02-06 66 views
0

所有解決數據我檢查如何讓所有的解決數據在$。當(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

我們可以得到所有的內部,然後使用參數

$.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'); 
    }); 
所解析數據