I am new to javascript. I have an array of promises that are for asynchronous Ajax calls using $.getJSON. The number of promises can vary. So to resolve them, I am using
$.when.apply($, promises).done(function(data) {
I am doing .apply because I don't know how many promises there are, so I give it an array of promises instead. The problem I am having is the data variable only returns data for the first promise. If I had two promises, I could do this
$.when.apply($, promises).done(function(firstData, secondData) {
But because the number of promises is unknown, I cannot setup the right arguments for the callback function in .done()
. I want to get an array containing the resolved data for each Ajax call in the .done()
callback if that is possible