hi there
here is my question.
I have a javascript function that gets called by clicking an element on the page which then performs some processing on some other elements on the page, this ends up taking some time because the processing is a bit complex.
So I figured I need to put some kind of loading/processing indicator while my js function is running so that the user knows that their click worked and shouldnt keep on clikcing since they dont see anything happening .. so this is what I did
here is my processing function
function doSomeWork(){
//in the start of this function I called another function that displays the loading message
showLoading(true);
// all the processing
//and after all processing is done – I take the loading message off
showLoading(false);
}
showLoading is a simple function that hides or displays a loading message div
function showLoading(state){
someDiv.style.display = state ? ” : ‘none’;
}
simple enough ..
now the problem is that for some weird reason when I run this and my doSomeWOrk function gets called .. it first finishes all the processing and then tries to display the loading image and then obviously since all the processing is already done it then hides the loading images rightaway .. so u still end up waiting for a few seconds for the processing to happen and then the loading images shows up and goes away right away ..
any ideas whats going on