Pass in an array of Deferreds to $.when()

Here’s an contrived example of what’s going on: http://jsfiddle.net/adamjford/YNGcm/20/ HTML: <a href=”#”>Click me!</a> <div></div> JavaScript: function getSomeDeferredStuff() { var deferreds = []; var i = 1; for (i = 1; i <= 10; i++) { var count = i; deferreds.push( $.post(‘/echo/html/’, { html: “<p>Task #” + count + ” complete.”, delay: count }).success(function(data) { $(“div”).append(data); … Read more

JavaScript variable number of arguments to function

Is there a way to allow “unlimited” vars for a function in JavaScript? Example: load(var1, var2, var3, var4, var5, etc…) load(var1) 12 s 12 In (most) recent browsers, you can accept variable number of arguments with this syntax: function my_log(…args) { // args is an Array console.log(args); // You can pass this array as parameters … Read more