How to display a “wait page” while CGI is running?

I have a cgi script that takes a long time (30 seconds) to generate results before printing html. I want to show a reseller page that says “Download, wait ...” with an animated GIF before displaying the results. Thanks

+4
source share
3 answers

Run the process and save the link to it in the session. Then periodically try the script to update the state.

There is a more detailed explanation with code examples that were originally published in Linux Magazine. Perl Monks further discussion .

You can use JavaScript (and XMLHttpRequest) to do your survey, and not reload the entire page (remember to rely on things that work ).

+4
source

A simple solution: make a static html page with the loading text and gif, and using a JS script load your CGI script using XHR . It is very simple with libs like jQuery and its helper ajax functions like load .

+4
source

Thanks guys for the help, here is what I did:

<script type="text/javascript"> var ray={ ajax:function(st) { this.show('load'); }, show:function(el) { this.getID(el).style.display=''; }, getID:function(el) { return document.getElementById(el); } } </script> <style type="text/css"> #load{ position:absolute; z-index:1; border:3px double #999; background:#f7f7f7; width:300px; height:300px; margin-top:-150px; margin-left:-150px; top:50%; left:50%; text-align:center; line-height:300px; font-family:"Trebuchet MS", verdana, arial,tahoma; font-size:18pt; } </style> <div id="load" style="display:none;">Loading... Please wait<br/><img src="images/loading.gif"></div> <form action="http://localhost/cgi-bin/test.cgi" method="get" onsubmit="return ray.ajax()"> <input type="text" value="Test" name="q"> <input type="submit" value="Search"> </form> 
0
source

All Articles