I have the following Ajax,I want to know when call back method of asynchronous Ajax call start execution.
statement 1;
statement 2;
statement 3;
statement 4;
statement 5;
jQuery.ajax({
url: "/includes/unit.jsp?" + params,
cache: false,
dataType: "html",
async: true,
success: function (html) {
statement 6;
statement 7;
}
});
statement 8;
statement 9;
statement 10;
statement 11;
.
.
.
statement 10000;
I know statement 1 to statement 5 will execute in order. As async: true, statement 8; will execute next, my question is
when will
statement 6; and statement 7;execute, will it execute all the statements after theajax calltillstatement 10000then executesuccess method. or at some point it got the response from server while executingstatement 500, executesuccess methodthen start executingstatement 501??
First,
async: trueis the default, no need to specify. Statement 6 will execute as soon as a success response comes back from the ajax request. It depends on many factors how much time it will take. Statement 7 will execute right after statement 6.