I want to click a button, show a loader image, execute a time-consuming function, hide the loader image. When I attempt this, the page freezes until the entire event runs, so the loader image is never seen.
Here is a sample:
$('#btn').click(function() {
$('#LoadingImage').show();
<time consuming function>
$('#LoadingImage').hide();
});
How can I distinctly show the loader image, update the screen, run the function, hide the loader image?