?
Solved

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

Posted on 2004-09-09
5
Medium Priority
?
263 Views
Last Modified: 2013-12-25
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();
}
0
Comment
Question by:sidikiisajawa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 500 total points
ID: 12024769
Try to flush the buffer before you print
print "Content-type:text/html\n\n";
with :

# ------------------------------------------
# Flush buffers and print MIME Content-type
# Header for the output HTML file
# ------------------------------------------

# flush STDOUT buffer
$| = 1;
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12024855
0
 
LVL 3

Accepted Solution

by:
cjmos earned 500 total points
ID: 12026653
Hi,

instead of disabling perl buffering with $| = 1 I'd use the built in IO::Handle module to automatically flush each line of STDOUT.

e.g:

#!/usr/bin/perl
use CGI':standard';
use CGI::Carp "fatalsToBrowser";
use IO::Handle;
STDOUT->autoflush(1);

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

wait_footer();


etc...

This works in IE, netscape and Mozilla.
0
 

Author Comment

by:sidikiisajawa
ID: 12030179
exactly what i needed, thanks :)
0
 

Author Comment

by:sidikiisajawa
ID: 12031128
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 http://www.experts-exchange.com/Web/Web_Languages/CGI/Q_21125344.html
0

Featured Post

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question