How do I use jQuery .when() function with a dynamic set of ajax calls? How do I use jQuery .when() function with a dynamic set of ajax calls? ajax ajax

How do I use jQuery .when() function with a dynamic set of ajax calls?


This may not work at all, in fact I'm curious as to whether or not it will. Try building the array of promise objects, then call $.when.apply(null, arr).done(function () { ... });

apply allows you to trigger a function and pass an array of arguments dynamically, such as in this case.