chuckd has asked for the wisdom of the Perl Monks concerning the following question:

I would like to display something on the screen while I read and perform logic on some db info. The logic might take anywhere from a few seconds to a couple of minutes and I don't want to stare at a blank screen. I'm using cgi and html to output to the screen. Isn't there a way to display something while the user waits for his request? Can anyone show me any examples?
  • Comment on displaying a screen while waiting for some computation

Replies are listed 'Best First'.
Re: displaying a screen while waiting for some computation
by moritz (Cardinal) on Dec 12, 2007 at 06:49 UTC
Re: displaying a screen while waiting for some computation
by citromatik (Curate) on Dec 12, 2007 at 09:34 UTC

    This re: could be a little off-topic, sorry about that, but maybe you could give Ajax a try. This is a very simple example of usage, surely you could find nice tutorials on the web

    The idea is to don't change the page while the cgi is doing its job

    Hope this helps

    citromatik
Re: displaying a screen while waiting for some computation
by narainhere (Monk) on Dec 12, 2007 at 11:12 UTC
    Though this a Perl forum, I am posting something related to HTML/Javascript because thats what you need. Save the below code as "index.html"
    <html> <body> <form name="myform" action="report.cgi" method="get"> <input type="button" value="Delayed Load" onclick="javascript:submitFo +rm(document.myform)"> </form> <div id="pleaseWaitDiv" style="display: none;"> <jsp:include page="loading.html"/> </div> <script language="javascript"> function submitForm(oForm) { // Hide the form document.getElementById('myform').style.display = 'none'; // Display progress page document.getElementById('pleaseWaitDiv').style.display = 'block'; oForm.submit(); } </script> </body> </html>
    put this in a file "loading.html"
    <html> <body> Loading!!!!!!!!!! </body> </html>
    Now the page "loading.html" would be displayed until "report.cgi" generates the page.Hope this helps.

    The world is so big for any individual to conquer