I have read many different posts about how to use done() with $.ajax(). As I understand it, ajax returns a promise so the done() should be executed on completion, which seems to be happening, however when in an each() loop, once the first ajax function is reached, the 2nd loop initiates while the first loop is still processing.
Here is a basic jsfiddle of the issue:
https://jsfiddle.net/kLja50xa/1/
My desired result is:
1-1
2-1
1-2
2-2
I have tried the option to push the requests to an array, but this means more nestsed each() ajax() loops with the same issue?
The reason I need to process these in order is that some instances within the loop require user input.
I can force the required result using async:false. but for obvious reasons I want to avoid this. Also this has additional impacts to the script whereby I cannot target and update a tracking message advising the user where the process is.