Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display partial page while it's still loading

Status
Not open for further replies.

msc0tt

IS-IT--Management
Jun 25, 2002
281
CA
I have a perl cgi that builds a page from a DB query. The cgi can take up to 30 seconds to complete, and I would like it to display the top portion of the page while the query is completing. I've seens sites that do this, but can't quite figure out how.
A simple example would be greatly appreciated.
-Mike
 
Mike,

I've not used CGI myself, but I imagine it would involve writing part of the document out, calling your query, and then writing the rest out.

Maybe the people in the CGI form (forum452) can shed more light on this?

Failing that, would using frames or an iframe be out of the question? If not, then you could display a holding message, run the query in another frame/iframe, then overwrite your holding message when the query returns.

Hope this helps!

Dan
 
write out as much as you can before doing the query is all I can think of... but I'm not familiar with perl, so I don't know if you can have multipule stream flushes per HTTP request in a perl script.
 
I'm assuming you're using DBI, right? According to the DBI FAQ, you shouldn't do any multithreading with it.

One thing you can try is retreiving only a certain number of rows at a time. I don't know how with other databases, but using MySQL you can do something like this:
Code:
SELECT * FROM table LIMIT 5,10;
which retreives rows 6-15. You could then probably set up some sort of a loop to retreive 10, 20, or whatever number of rows at a time until no more rows are retreived.

 
Thanks for the replies.

My Perl CGI (on Linux w/Apache) does the following:
-prints the HTML header tags
-prints some informative paragraphs
-prints the column headings
-performs the query!!
-prints query results
-prints the HTML footer tags

I have set the STDOUT stream to NOT buffer ($|=1;)
The query is not DBI - it simply recurses a bunch of files (thousands) and extracts specific information.

What I had hoped was that my browser would display everything up to the "query" point, delay, then complete displaying the rest of the page when done. What it does is pause until the entire page is complete, then displays it.

I was hoping there was some sort of HTML header tag that effectively says "progressively display page while it is received".

-again, thanks for the replies.
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top