1$.when(ajax1(), ajax2(), ajax3(), ajax4()).done(function(a1, a2, a3, a4){
2 // the code here will be executed when all four ajax requests resolve.
3 // a1, a2, a3 and a4 are lists of length 3 containing the response text,
4 // status, and jqXHR object for each of the four ajax calls respectively.
5});
6
7function ajax1() {
8 // NOTE: This function must return the value
9 // from calling the $.ajax() method.
10 return $.ajax({
11 url: "someUrl",
12 dataType: "json",
13 data: yourJsonData,
14 ...
15 });
16}
1 $(document).ajaxStart(function () {
2 $('#ajax-loading-image').css("display", "block");
3 });
4 $(document).ajaxStop(function () {
5 $('#ajax-loading-image').css("display", "none");
6 });