If you're on the lookout for a solution, I hope this guide can assist you!
To troubleshoot in Chrome browser, go to rightClick/inspect/networkTab/xhr? and hover over the timeline where your requests are being processed like shown in the image below:
https://i.stack.imgur.com/XHE9K.png
HERE'S MY ASYNC CODE (default ajax)
`$.ajax({
type: "GET",
contentType: "application/json", // data type of request
url: //url,
data: //data,
dataType: "json", // data type of response
success: function (result) {
// code goes here
}
});`
I encountered issues while making multiple asynchronous ajax calls to localhost where each call depended on the previous response. The responses should have been received in order but due to simultaneous sending of requests, they arrived out of sequence. Refer to the timing diagram below showing the problem (check the waterfall tab).
https://i.stack.imgur.com/HDuKV.png
THIS IS MY SYNC CALLS CODE (async: false in ajax)
$.ajax({
async: false,
type: "GET",
contentType: "application/json", // data type of request
url: //url,
data: //data,
dataType: "json", // data type of response
success: function (result) {
// code block here
}
});
https://i.stack.imgur.com/MRVEt.png
How can one confirm if async: false is functioning correctly?
In async mode, the timings of ajax calls overlap, whereas in synchronous mode (async: false), the timings are clearly separate, thereby validating that sync calls [async: false] are operating effectively. If there's still overlapping timings, then it indicates an issue with synchronous calls, unlike my scenario.