[jQuery] How to wait or freeze between 2 statements
Hi,
What I want to achieve is that the user click "Build" and the "Preview" links gets updated with the new link. Before the link is updated, it is replaced by a "Loading..." msg. This is working perfectly.
What I cant figure out is that can I make the browser wait for half a second after loading so that the user sees something changing and gets a cue that the link has been updated. Right now everything is happening in a split second and the link gets update quicker that the user can notice.
here's the code...
$("#preview_link").empty();
$("#preview_link").append("Loading...");
//WAIT or FREEZE STATEMENT HERE
$("#preview_link").empty();
$("#preview_link").append(x);
Can someone suggest how I can write this "WAIT statement". setTimeout("doSomething", 2000) does not work because it waits for "doing something" not the next statement.
Thanks,
Gurpreet