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("w ait").styl e.display = "none"
document.getElementById("c ontent").s tyle.displ ay = "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();
}
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\
print qq{
<html>
<head>
<title>Please Wait...</title>
<Script>
function showContent() {
document.getElementById("w
document.getElementById("c
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
exactly what i needed, thanks :)
ASKER
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
https://www.experts-exchange.com/questions/21125344/Unbuffered-output-to-browser-while-CGI-script-is-still-processing.html