mirada a este post y respuestas ... https://stackoverflow.com/a/13090589/999958
Un útil solución para mí: Mire la llamada ajaxCallComplete() en cada .complete (...);
$(document).ready(function(){
loadPersons();
loadCountries();
loadCities();
});
// Define how many Ajax calls must be done
var ajaxCalls = 3;
var counter = 0;
var ajaxCallComplete = function() {
counter++;
if(counter >= ajaxCalls) {
// When all ajax calls has been done
// Do something like hide waiting images, or any else function call
$('*').css('cursor', 'auto');
}
};
var loadPersons = function() {
// Show waiting image, or something else
$('*').css('cursor', 'wait');
var url = global.ctx + '/loadPersons';
$.getJSON(url, function(data) {
// Fun things
})
.complete(function() { ajaxCallComplete(); });
};
var loadCountries = function() {
// Do things
var url = global.ctx + '/loadCountries';
$.getJSON(url, function(data) {
// Travels
})
.complete(function() { ajaxCallComplete(); });
};
var loadCities = function() {
// Do things
var url = global.ctx + '/loadCities';
$.getJSON(url, function(data) {
// Travels
})
.complete(function() { ajaxCallComplete(); });
};
La esperanza puede ayudar a ...
RELACIONADO: [Esperando en asíncrona de varias llamadas para completar antes de continuar] (http://stackoverflow.com/question s/2768293/waiting-on-multiple-asynchronous-calls-to-complete-before-continuing) –