I have a list of itens to pass through a function that returns a $.ajax()
but the .done
is getting called after the $.each
is called, not after the inners ajax calls complete! What should I do?!?
Here is my code:
$.when(
$.each(data, function (index, item) {
GetReservation(
item.UniqueId,
apiRoot,
//this is the 'success' function
function (data2) {
//do my stuff
},
//this is the 'error' function
function (x, y, z) {
if (x.status == 404) {
//OK, no reservations!
}
});
})
).done(setButtons(box, c));