I have an expensive function, createNewWindow(). I want to show a progress indicator when the method gets called, and then hide that indicator when the function finishes. Everything I've tried though, I don't see the progress indicator until the method has finshed, so I'm trying to call that method asychronously (and failing).
I tried this:
$( "#submit" ).click( function () {
$("#progress").show();
$.Deferred(createNewWindow());
} );
And the last line of createNewWindow was $("#progress").show(). Didn't work. Before that I tried:
$( "#submit" ).click( function () {
$("#progress").show();
setTimeout(createNewWindow(), 0);
} );
Same effect.
What's the right way to do this?
I saw a few other SO posts like this that describe using setInterval or setTimeout, but I was unable to get them to work like I was expecting.