Re: Perl:CGI - Creating a Please wait message



<wjharrisiii@xxxxxxxxxxxxx> píse v diskusním príspevku news:1171642388.838134.117810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have created a CGI program which dynamically creates an HTML FORM.
This form upon submit, goes out and does some work that can take up to
10 minutes to complete. Once done, the called CGI provides the user
with logged results.

My goal is to provide the user with an automated GIF and a message to
please stand by while the program is out doing its work.

I have tried to first display this "Please wait ... processing your
transaction" message at the beginning of the called CGI called
program, before any work is done. I have also tried to call an
intermediary CGI program which displays the message and calls the
working CGI in the background.

In all cases, the message is not displayed until after the CGI working
program [which takes 10 minutes to complete] has actually completed!

Try to put
$| = 1; // switch to unbuffered output mode
at the begin of your script.
Many browser used to don't display content until receive needed bytes from server. A little trick is to send to browser some spaces (0x20 character). Browser must receive these spaces but show only one.

Example:

use strict;
$| = 1;
print "Content-type: text/html\n\n<head><body>\n<p>Please wait ... processing your transaction";
my $time = 0;
while($time < 30)
{
print ' 'x1024;
sleep 2; # or do something other
$time++;
}
print " <b> - Done</b></body></html>\n";


--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail from another non-spammer site please.)


.



Relevant Pages

  • Re: How to send a key event to another process?
    ... Browser sends a GET or POST HTTP request to web server ... Web server decodes GET/POST URL and determines which CGI program to call ...
    (comp.os.linux.misc)
  • Re: CGI and checkboxes
    ... You might want to invest in an introductory book on CGI programming. ... Browser sends request to some web server for some page. ...
    (comp.lang.ruby)
  • Re: cgi problem
    ... > I'm very new to CGI programming. ... > Browser: Mozilla Firefox ... > window, it said "Internal Server Error". ... > chmod command in Windows XP. ...
    (perl.beginners)
  • Re: webbrowser
    ... I am trying to open a URL on a new browser or new tab from an HTML page created from a python cgi script. ... A 500 Internal Server Error is displayed on the browser. ... What your code does is make whichever computer is running the cgi code open a browser pointing to http://www.google.com. ... It works on your home machine, because you have a graphical interface running and python can open whatever browser it chooses. ...
    (comp.lang.python)
  • Re: webbrowser
    ... I was not aware that the cgi was trying to open ... I am trying to open a URL on a new browser or new tab from an HTML page ... created from a python cgi script. ... to a remote server, it does not. ...
    (comp.lang.python)