If you are using jQuery 1.5 or better, you can use the heavenly construct $.when, which uses $.Deferred, first implemented in this version of jQuery. You can run a function (or several functions) when all several AJAX requests are complete.
So your code will look like this:
$.when($.ajax({
url: "page1.php",
dataType: "html",
type: 'POST',
data: "value=" + value,
success: function (data) {
}
}), $.ajax({
url: "page2.php",
dataType: "html",
type: 'POST',
data: "value=" + value,
success: function (data) {
}
}), $.ajax({
url: "page3.php",
dataType: "html",
type: 'POST',
data: "value=" + value,
success: function (data) {
}
})).then(function () {
});
source
share