if ($('#loading').visible()) { //if #loading not visible show it, prevent default, set timer to re-submit.
return; //submits form.
}
$('#loading').show();
event.preventDefault()
setInterval(function(){ $('#queryForm').submit() },1000);
});Won't guarentee it'll work, but it should..
The professional method to achieve the desired effect is a bit more involved.
To achieve the desired effect, use ajax to an url that returns json response, which is a bit involved to setup.
Basically, you use javascript to issue an ajax call to another url which loads data from the query. At the time of the initial ajax call, you show the #loading <div>
When the ajax call receives it's response, you hide #loading and display the json data in another <div> where appropriate.
The ajax call doesn't load a fresh, it fetches json data. json data is more compact than html, so this has the side-effect of transferring faster. Less work for the web server and less traffic between server and browser. However!!! This requires more preparation.
Try the kludge, it might actually work. Then invest time implementing an ajax solution.