Dialog not closing until AJAX success/error function completes
I am using a modal dialog to display a "please wait" spinner while I call an AJAX function to fetch some data. When the AJAX call completes I close the dialog. However if I throw an alert in the AJAX success or error handler after closing the spinner dialog, the alert displays while the spinner is still visible. I tried using the dialog close event handler, but the behavior is the same. It's looking like the spinner dialog isn't actually hidden until the AJAX success or error function completes. So my sequence, assuming success, is $("#pleasewait").dialog("open"); $.get(url, query, function () { $("#pleasewait").dialog("close); alert("my message") });
How can I get the spinner dialog to close completely before the alert is displayed?