Am I using the wrong approach for deferreds and promises?
Yes. In the asynchronous callback you should not access promises
, but only the callback arguments. The return promise of $.when
does resolve with an array of the .resolve()
parameters for each of the promises in the array – you can loop over the arguments
object to access the results:
$.when.apply($, promises).then(function () {
for (var i = 0; i < arguments.length; i++) {
var singleresult = arguments[i][0];
console.log(singleresult);
}
});