Link to home
Start Free TrialLog in
Avatar of sidikiisajawa
sidikiisajawa

asked on

please wait message - tell browser to begin opening page so wait message is displayed right away. . .

hello,

 I have cgi which accesses a very large datafile, does some processing and displays the results.  I set up a wait message for this page using the method shown below (see waitpage method).  

The Problem:  the browser does not want to start loading the page (which includes the wait message) until the script is almost finished processing (or perhaps it is waiting for a certain amount of data to be returned before it starts rendering to the next page.)  

I have bypassed this problem by cheating and printing a bunch of spaces before the cgi does the bulk of the processing.  This works, but then of course, it is a waste of time, and it puts a bunch of spaces in the html page source.  

Can someone point out the correct way to do this?

thanks!

waitpage method:
----------------------------------------------------------------------------------------------
#!/usr/bin/perl

wait_header();

#access database
   (some code here);
#process data
   (more code here);
#print results
   (more code here);

wait_footer();


sub wait_header{

print "Content-type:text/html\n\n";
print qq{
<html>
<head>
<title>Please Wait...</title>

<Script>
function showContent() {
  document.getElementById("wait").style.display = "none"
  document.getElementById("content").style.display = "block"
  window.document.title = "Finished";
}
</Script>
</head>
<body onLoad="showContent()">

<div id=wait>
<h3>Accessing Database<h3>
<p>Please wait . . .</p>
<img src="waitbar.gif">
</div>

<div id="content" style="display:none;">
};
}

sub wait_footer{
print qq{
</div>
};
html_footer();
}
SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sidikiisajawa
sidikiisajawa

ASKER

exactly what i needed, thanks :)
both methods work just the same for what I am doing - since I only care about flushing the buffer, and not about print as you go they are doing in https://www.experts-exchange.com/questions/21125344/Unbuffered-output-to-browser-while-CGI-script-is-still-processing.html