如何从 jQuery 中通过 $.when 解析的多个承诺对象中检索数据?

How to retrieve data from multiple promise objects resolved through $.when in jQuery?

假设我们只有一个像下面这样的 promise 对象。

var myPromise = $.get(url1);
myPromise.done(function(data){
    console.log(data);
});

我们能够从 promise 对象访问数据。现在假设,我们有多个通过 $.when

解析的 promise 对象
var multiplePromises = $.when($.get(url1),$.get(url2),$.get(url3));
multiplePromises.done(function(){

});

必须满足上面的要求,即只有所有的get请求都完成了,done的部分才会被执行。但是我如何在 $.when.done() 方法中单独获取每个 get 的数据响应以与它们一起工作?

你得到它们作为参数。

function get(what) {
  return $.when(what)
}

$.when(get(1), get(2), get(3)).done(function(first, second, third) {
  console.log(first, second, third)
})
<script src="https://unpkg.com/jquery@3.2.1/dist/jquery.js"></script>