Showing Loading Div for SJAX Requests
In my current project, I am using SJAX (i.e. synchronous AJAX) requests instead of pure AJAX requests in several places for better usability. One place is on the "unload" event, where the XMLHttpRequest must be synchronous in order for the program to work.
Anyway, when there is latency on the server, especially in peak traffic hours, it can be confusing to the user to see a frozen page for a couple of seconds while the SJAX request loads. As such, it would be beneficial to have a "loading" div reveal itself while the loading is taking place.
Here is the concept I currently have in place:
This works as expected in Firefox and Opera, although Opera is a little sluggish at first. However, Safari and Chrome continue to show the frozen screen without displaying the loading div, despite this code. I have not yet tested IE. Oddly enough, when I put a quick alert like "alert('hi there!');" before "Start Request" and after the display activating script, the loading div will appear in WebKit and will remain in sight for the duration of the request.
document.getElementById("sjaxsubmitting").style.display = "block";
// Start Request
reqobj.open("POST", "myfile.php", false);
// Finish Request
document.getElementById("sjaxsubmitting").style.display = "none";
What could I change to make WebKit display the div in the same way Firefox does?