DOM Updates blocked during async ajax request
I am fairly new to jQuery but have been able to do some pretty neat stuff with it however I have recently run into an issue. I have 2 ajax requests that are fairly simple. One starts a rather long SQL process and the other is called by recursive javascript function and updates a progress bar. The problem is that none of the UI/DOM updates that the second process performs become visible until after the first process finishes. Kinda makes the progress bar useless. I even tried eliminating the 2nd ajax call (just for testing) and updating the progress bar from a timed loop but I get the same results. Nothing on the screen until after the process finishes and then all the changes are applied.
The long call. Note that I commented out the success function hoping it wouldn't wait for the script to finish but it still does.
- $.ajax({
- type: "POST",
- url: '<?= $_SERVER['PHP_SELF'] ?>',
- data: jsonStr,
- timeout: 300000,
- global: false
- contentType: "application/json"
- // success: function(data){
- // $('#complete').html(data);
- //
- // }
- });
The quick, repeating call to update the status bar. Note the data returned is the actual status bar update the #timer update is a debug bar that just updates by one pixel on each iteration just so I can tell if it's running or not.
- $.ajax({
- type: "POST",
- url: '<?= $_SERVER['PHP_SELF'] ?>',
- data: jsonStr,
- contentType: "application/json",
- global: false,
- success: function(data){
- $('#progress').html(data);
- w = $("#timer").width() + 1;
- $('#timer').css("width",w + 'px');
- }
- });
-