Tengo una cadena profunda de tres capas de llamadas ajax diferidas, e idealmente van a patear la promesa hasta el final cuando la capa más profunda termine (me hace pensar en Inception. .. "¡necesitamos ir más profundo!").jQuery diferido - esperando múltiples solicitudes AJAX para terminar
El problema es que estoy enviando muchas solicitudes ajax (posiblemente cientos) a la vez y necesito diferirlas hasta que todas hayan finalizado. No puedo confiar en que el último se haya hecho al último.
function updateAllNotes() {
return $.Deferred(function(dfd_uan) {
getcount = 0;
getreturn = 0;
for (i = 0; i <= index.data.length - 1; i++) {
getcount++;
$.when(getNote(index.data[i].key)).done(function() {
// getNote is another deferred
getreturn++
});
};
// need help here
// when getreturn == getcount, dfd_uan.resolve()
}).promise();
};
http://stackoverflow.com/questions/3709597/wait-until -all-jquery-ajax-request-are-done/9350515 # 9350515 – Benjamin