Forcing Javascript to Wait For AJAX

A common problem I ran into as I learned AJAX was that the javascript wouldn’t wait for the AJAX to return the content I asked for. That is because of the “A” in AJAX. AJAX is asynchronous. This means that it will send the request out and will get a response back in an indeterminate amount of time. The frustrating part is that the javascript will not wait for the response from AJAX. This in turn produced very inconsistent results depending on what ran faster. To resolve this one must find out if the AJAX is done executing before continuing …

Continue Reading