Here is what I'm using:
I learned that most people prefer this:#!/usr/bin/perl $|=1; print '<header>'; # placeholder for your whole HTML header block print '<span id=Progress>Working...</span>'; print '<footer>'; # placeholder for the rest of your document until bu +t without </body> sleep 1; # Something is done here print <<_EOT_; <script language=JavaScript type=text/javascript><!-- document.getElementById('Progress').innerHTML='Still working...'; //--></script> _EOT_ sleep 1; # Something is done here print <<_EOT_; <script language=JavaScript type=text/javascript><!-- document.getElementById('Progress').innerHTML='Sorry, still not finish +ed...'; //--></script> _EOT_ sleep 1; # Something is done here print <<_EOT_; <script language=JavaScript type=text/javascript><!-- document.getElementById('Progress').style.display='none'; //--></script> _EOT_ print '</body></html>'; # Page finished
Once I had a customer waiting three hours for the result not knowing that his internet connection broke early after starting the job.#!/usr/bin/perl $|=1; print '<header>'; # placeholder for your whole HTML header block print '<img src=animated.gif id=Progress>'; print '<footer>'; # placeholder for the rest of your document until bu +t without </body> sleep 1; # Something is done here sleep 1; # Something is done here sleep 1; # Something is done here print <<_EOT_; <script language=JavaScript type=text/javascript><!-- document.getElementById('Progress').style.display='none'; //--></script> _EOT_ print '</body></html>'; # Page finished
These solutions are not the best ones - they don't use any modules. But they're simple and work for me in a number of projects. You could also output your data & footer after finishing the processing. In this case, add a <br>\r\n behind the Progress-object to force flushing the buffer (\r\n), sending to the client and showing to the user (<br>).
In reply to Re: how to add progress bar to the CGI script
by Sewi
in thread how to add progress bar to the CGI script
by ashwin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |