Possible Duplicate:
How to make GIF rotate when the tree is loading in Javascript
Like the title says, my loading gif freezes while going through an ajax success call. The success call has some heavy DOM manipulation to do, and since the UI is single threaded, it causes my loading gif to freeze.
So far I have tried to
Is there any way to get around this?
Any help is very much appreciated.
EDIT 1:
It's related to ArcGIS javascript, where I have to retrieve about 4000 rows from the database, and then show points at the correct latitude and longitude via a for-loop that goes through all the points.
I'm trying to make a simple overview like this one?.
You have to emulate multithreading in order to let the UI remain responsive while the AJAX response is processed.
The only non-trivial part of this is to arrange the processing function so its task can be splitted and performed by steps.
As you have got the data you call:
function ProcessData() {
var done = false;
/*
access the data here and perform a "bit" of data processing.
if the task finishes set done to true
*/
if(!done) {
setTimeout(ProcessData, 100); // this gives the UI 0,1 secs
}
}
Of course the above function must be have some way to access the data (with a global or, better, properly setting its context), register the progress of the operation and so on.
It's just to give an idea but there is a lot on the web that explains in detail.
Or you may get a copy of "Secrect of the JavaScript Ninja" and read the chapter "Taming threads and timers".
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With