Updating Javascript UI only when alert () is used in Internet Explorer with AJAX

I have a problem in Internet Explorer, it works fine with Firefox.

I have a java script function that updates the user interface (screen contents) that is called before the AJAX function. But it does not update the user interface until it is prompted to use a warning window. Without a warning window, it does not update the interface before the AJAX function. It updates the interface after the AJAX function, even if it is called before the AJAX function

If I use the following code, UpdateUI () does not update the user interface at all before calling the AJAX function, it updates the interface after calling the AJAX function. I want it to update the user interface before calling the AJAX function (in fact, it displayed the loading bar before calling the AJAX)

UpdateUI(); // java script function, it just updates inner HTML of a DIV // AJAX function call here with Async = false 

But if I use the following code, UpdateUI () updates the interface before calling the AJAX function, but this method includes a hint. I do not want to use alerts

 UpdateUI(); // java script function, it just updates inner HTML of a DIV alert('hellow'); // AJAX function call here with Async = false 

It works fine in Firefox, but not in Internet Explorer 8

+4
source share
1 answer

Browsers usually do not update (update) the user interface when there is an active JS stream. It waits until it clears all events from the ts event queue before performing a rescheduling. Think of it as the only stream loop in which the browser must execute all of its events.

Reflow usually takes the least priority in certain situations, however you can force the browser to re-configure by requesting some attributes on DOM elements like getComputedStyle or offsetX / y etc. Basically, any request that requires a browser layout of the user interface to respond will be paid.

This is the best article I once found when faced with a similar problem.

The simplest and flawless trick I can offer is to split your code into two methods and call a method that requires a preliminary reboot to timeout after 0mills. This gives the browser some respite to re-melt before invoking method2. This works just like the alert () trick you tried and found a job.

+10
source

All Articles