I'm using jQuery's .when()
to wrap an array of promises so that I can do some action when all promises have been resolved.
$.when.apply($, requests).done(function () {
console.log(arguments); //it is an array like object which can be looped
var total = 0;
$.each(arguments, function (i, data) {
console.log(data); //data is the value returned by each of the ajax requests
total += data[0]; //if the result of the ajax request is a int value then
});
console.log(total)
});
Suppose I wanted to be notified when each individual promise was resolved, as a way to show progress. For instance, if requests
has 50 requests and 3 of them are resolved, I would like to be able to display a progress bar at 6%. Is there a way to use $.when
so that it can return an overall progress without modification of the inside promises and their progress events?