Calling these three ajax requests synchronously freezes your browser. You will be better off using jQuery Deferred objects. Try the following:
function getData(Code) {
return $.post('/adminA/GetData', { Code: Code }, function (data) {});
}
getData(0).done(function() {
getData(1).done(function() {
getData(2);
});
});
Adding
You should also consider combining your calls into one and changing the server logic to handle it. This will ultimately be faster than three queries:
function getData(firstCode, secondCode, thirdCode) {
$.post('/adminA/GetData', {
codeOne : firstCode,
codeTwo : secondCode,
codeThree : thirdCode
}, function (data) {});
source
share