I would like to iterate array of URLs, retrieve json data from each URL and push it as new element of my array called returned_data. Only when all json URLs have been fetched I would like to do something with returned_data.
How can I accomplish this?
Here is my lousy attempt that does not work because for loop is not allowed inside $.when:
var base_url = "http://app.loc/";
var urls = [
  base_url + "1.json",
  base_url + "2.json",
  base_url + "3.json"
];
var returned_data = [];
$.when(
  for ($i = 0; $i < urls.length; $i++) {
    $.getJSON(urls[$i], function(data) {
      returned_data.push(data);
    });
  }
).then(function() {
  console.log(returned_data);
});
 
    