I am trying to make an ajax call for each item in an array. Right now i throw all the promises into an array and then do $.when.apply...
// throw all the promises into an array
_.each(birds,function(bird,i){
birds[i] = getBird(bird) // getBbird returns $.ajax(...)
});
// do $.when.apply
return $.when.apply($,birds).then(function(res){
console.log("bird is the word",res)
});
My initial SO search basically confirmed I am doing this "the way" it should be done. But apply
feels so hacky. Is there a more standardized/common jQuery way to achieve this?
Thanks in advance.