Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a "waiting page" while a CGI is running?

Tags:

html

cgi

perl

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

like image 946
Mushal Avatar asked Dec 28 '22 13:12

Mushal


2 Answers

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).

like image 92
Quentin Avatar answered Dec 30 '22 06:12

Quentin


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.

like image 32
Adam Jurczyk Avatar answered Dec 30 '22 06:12

Adam Jurczyk