There seems to be an issue with a visual effect not displaying in a timely manner when the call is made, rather there is a significant delay that renders it ineffective.
I am attempting to retrieve data synchronously (yes, you read that correctly, not asynchronously), display a "waiting" indicator while the retrieval is in progress, and then hide the indicator once the operation is complete. However, the problem lies in the fact that the indicator does not appear when the code responsible for it is executed; The expected visual outcome of a jQuery show() function is being delayed until after the data retrieval process. I have verified through timestamp logging in the console that the show() function indeed occurs prior to the data retrieval.
Peculiarly, the console logging itself is also visually delayed even though the timestamps indicate that the code execution happens as anticipated.
A noteworthy observation is that if an alert() call is introduced before the data retrieval, all visual processes occur immediately when the alert pops up, without waiting for the data retrieval to finish.
Below is the provided code snippet. It should be noted again that the data retrieval is done using a synchronous $.ajax() call (i.e. async: false).
fillInClient: function(clientId) {
var result, spinner;
console.log("spinning at " + ($.now()));
spinner = $("tr#client_" + clientId + " .spinner");
spinner.show();
// If I call alert("foo") here, I see both the spinner.show() and
// the first console.log immediately. After a few seconds,
// I see the hide() and the second console.log
// Without alert(), I never observe the show() and the first console.log
// only appears after this:
// This operation takes several seconds
result = $.ajax({
type: "GET",
url: "/advisor/householding/accounts?user=" + clientId,
async: false
});
spinner.hide();
console.log("stopping at " + ($.now()));
return result;
}
The console output shows simultaneous appearances, but the timestamps clearly indicate a time difference of several seconds between them.
spinning at 1418933857688
stopping at 1418933862374
Your assistance on this matter would be greatly appreciated...