I am have a JavaScript that is not running in sequence. The script establishes an unload function. It uses the $.get jQuery command to retrieve a file, then it is supposed to print the file to the external device. I added some alert boxes, so I would know whether it is running every function, and I discovered it is trying to print before it is retrieving the file. I changed my code so it retrieved the file on an unload function, the prints the file on an on click function and it works perfectly. Is there a reason the it is running the $.get command out of sequence?
Share
AJAX requests get sent, but the processing continues – it does not stall until the response is received.
So if you want things to go sequentially you need to do the processing in a closure:
Not: