What is returned from getTickets function?
function getTickets(needsTickets) {
return $.when.apply($, $.map(needsTickets, function(x) {
return function(x) { return $.ajax() } ;
}));
}
Let's analyze what is happening:
The result of $.when
is a promise and that is what is being returned.
$.when
doesn't accept an array as arguments so to handle an array of promises you need to do:
$.when.apply( context, promiseArray);
The promise array is being created by $.map