I have a cgi script that takes long time (30 sec) to generate the results before printing out the html. I want to show an intermediary page that says "Loading, please wait..." with an animated GIF before displaying the results. Thanks
Fork the process and keep a reference to it in a session. Then poll the script periodically for a status update.
There is a more detailed explanation with code examples that was originally published in Linux Magazine. Perl Monks has further discussion.
You could use JavaScript (and XMLHttpRequest) to do your polling instead of reloading the whole page (do remember to build on things that work though).
Simple solution: Make static html page, with your loading text and gif, and with an JS script loading your CGI script with XHR. It is very simple with libs like jQuery and its ajax helper functions like load.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With