0
Результат
Javascript: -
$(document).ready(function(){
$("#result").html("function started here");
var requests = Array();
requests.push($.get('https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA'));
requests.push($.get('https://maps.googleapis.com/maps/api/geocode/json?address=EGL, Bangalore'));
var defer = $.when.apply($, requests);
console.log(defer);
defer.done(function(){
$("#result").html("Completed");
// This is executed only after every ajax request has been completed
$.each(arguments, function(index, responseData){
// alert(index);
$("#result").html(responseData);
// "responseData" will contain an array of response information for each specific request
});
});
});
выше фрагмент кода работает только тогда, когда все ajax calls возвращает ответ «success». Есть ли способ, которым я могу знать, получает ли все вызовы ajax ответ, может быть, это «успех»/«сбой».
Спасибо venkat :-) Это помогло. –
есть ли способ узнать, какие вызовы ajax не удались, а какие ajax - успешные? –
no .. (ajaxStart, ajaxStop, ajaxError, ajaxSuccess.) Эти функции запускаются глобально. Существует один способ, отслеживание с помощью значения retrun. – RJV