Hello.
At first I want to say I know it's not strictly jQuery issue but there
are many Javascript skilled people here that may know best so I hope
you forgive me... ;)

Ok, so here's a problem: I have a following function in which I change
some DOM elements:
function ttt(){
   $('#test').html('<p>Testing...</p>');
   pause(3000);
}

function pause(milliseconds) {
   var dt = new Date();
   while ((new Date()) - dt <= milliseconds) { /* Do nothing */ }
}

(The pause function is there to simulate ajax synchronous call that
can sometimes slow down the execution)
The problem is that the DOM changes takes effect only after the
function has finished processing, that is, it pauses for 3 seconds and
only then changes the DOM... Is that a standard Javascript
functionality...?

I want to do something like this:
function ttt(){
   $('#test').html('<p>Testing...</p>');
   pause(3000); // here I make an ajax call $.ajax(...)
   if(ajax_call_succesfull) $('#test').html('<p>Success.</p>');
   else $('#test').html('<p>Error.</p>');
}
but the 'Testing...' does not show up immediately... Instead it waits
until the ajax call is finished and then I don't need it any more...
So is there any way to make it work like I would like it to...? I'm
open to any suggestions...

--
nowotny

Reply via email to