Hi guys I need some help here, to my bad thinking brain :
I have an object :
var ch = [function1(), function2(), function3(), function4()];
function example:
function function1()
{
return $.ajax({
type: "GET",
url:url,
dataType:"jsonp",
success: function(data){}
});
}
i need to pass somehow this object here :
$.when(function1(), function2(), function3(), function4()).done({
function(data1, data2, data3, data4)
});
of course this idea is wrong:
$.when(ch) -- which is wrong
can you help with with this? Or Maybe it is a wrong way to do?
can you advice me ?
Thanks !
I think you mean to say you want to do an action when all the
Deferreditems in an array have been resolved. This is very easy using theapplymethod, which uses the members of an array as the arguments given to a function:See
applyin the MDN docs for more information on the method. Boiled down, the first argument is the context of the call (i.e. what will bethisinside the function; here you want to keep it as$, the jQuery object) and the second is an array whose members will be applied as the arguments to the function.