Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Send two documents to browser? - repost (http://www.velocityreviews.com/forums/t882998-send-two-documents-to-browser-repost.html)

Mark 10-08-2003 08:56 AM

Send two documents to browser? - repost
 
Hi All,

This is a repost of an earlier question as I don't think I made the
problem explicit enough, or highlighted the dependence on a perl based
solution.

I have a commercial perl search engine script that is slow in
producing results. As a consequence, once the user presses the search
button he/she has to stare at a glaring white blank screen until the
results are returned. I would like the script to send a temporary
document to the browser until the search is complete and then replace
this document with the search results.

It has been suggested in earlier replies that I use an interstitial
page and browser redirects to achieve this but I don't see how this
will work as if the script returns a temporary page which then
redirects, where will it redirect to? If it calls the script again
then we are no further forward.

The search engine is part of a complex shopping basket and we have
neither the expertise or the budget to make major changes to the
application. What I am hoping to find is a perl solution that I can
insert at the start of the search script that will send out the
temporary page while still allowing the script to do the searches and
then replace the temporary page with its results. We thought we had
solved the problem but instead of the search results replacing the
temporary page they were added below the temporary page, causing
essential header information to be printed rather than being
interpreted by the browser.

I have heard that perl TK is able to return yes/no pop ups whilst
still allowing the script to run in the background. Does anyone know
if perl TK could produce the required temporary document?

Is there any way I could fork to a process that would send the
temporary document yet still allow the search script to replace this
document once it is completed?

Many thanks for your interest, any information is gratefully received.

Mark


The previious post.
> Hi All,
>
> I have a commercial website search script which is slow in returning
> its results. The consequence is that for a short period the screen is
> white until the results are returned.
>
> Is there a simple way to make the script return a temporary document
> to the browser which is then replaced by the search results?
>


Yes, there are simple ways to do this. However, they are no more
Perl-specific than they are Cobol-specific. Rather than give you a
whole
solution here (and encourage more non-Perl-specific questions,
drowning
out those with Perl questions), I'll mention "interstitial pages",
"browser redirects", and point you toward Google and the
comp.infosystems.www.authoring.cgi newsgroup.

Gregory Toomey 10-08-2003 09:09 AM

Re: Send two documents to browser? - repost
 
It was a dark and stormy night, and Mark managed to scribble:

> Hi All,
>
> This is a repost of an earlier question as I don't think I made the
> problem explicit enough, or highlighted the dependence on a perl based
> solution.
>
> I have a commercial perl search engine script that is slow in
> producing results. As a consequence, once the user presses the search
> button he/she has to stare at a glaring white blank screen until the
> results are returned. I would like the script to send a temporary
> document to the browser until the search is complete and then replace
> this document with the search results.
>
> It has been suggested in earlier replies that I use an interstitial
> page and browser redirects to achieve this but I don't see how this
> will work as if the script returns a temporary page which then
> redirects, where will it redirect to? If it calls the script again
> then we are no further forward.
>


vbulletin does this sort of thing. Its written in PHP and you can download a demo version http://www.vbulletin.com/

When you do a search, it displays a page saying that is doing the search, then displays whe results. Have a look at the HTML code that it generates.

gtoomey

tom 10-08-2003 02:37 PM

Re: Send two documents to browser? - repost
 
Mark (tiscaliX.co.uk) wrote:
>Hi All,
>
>This is a repost of an earlier question as I don't think I made the
>problem explicit enough, or highlighted the dependence on a perl based
>solution.
>
>I have a commercial perl search engine script that is slow in
>producing results. As a consequence, once the user presses the search
>button he/she has to stare at a glaring white blank screen until the
>results are returned. I would like the script to send a temporary
>document to the browser until the search is complete and then replace
>this document with the search results.
>


You might want to use Javascript to do that. For example, the following script
mycgiscript.pl will generate an input form for the search, when the form is
submitted it will create a popup window telling the user that the search is in
progress - meanwhile your script can continue process the search results, when
done the popup window will close.

#!/usr/bin/perl

use strict;

### process your search results when the form is submitted
if(@ARGV)
{
print <<HTML;
Content-Type: text/html

<html><head><title>Search results</title></head>
<body><h3>Search completed...</h3>
Here are the results...

HTML
sleep(10); # show your search result here

exit;
}

### generate your search form here
print <<HTML;
Content-Type: text/html

<html><head><title>Popup window</title></head>
<body onUnload='javascript:msg.window.close()'>
<script language='JavaScript'>
function warning()
{
msg = window.open("","msg","width=600,height=150");
msg.document.open("text/html");
msg.document.write("<br><br><h2 align=center><font color=red>Searching
in progress...</font><h2>");
return true;
}
var msg;
</script>

<h3>Search for...</h3>

<form method="post" action="mycgiscript.pl?testing" onSubmit='return warning
()'>
<table>
<tr><th>Search for</th><td><input /></td>
<tr><td><input value="SEARCH" type="submit" /></td>
</tr></table></form></body></html>

HTML

### end of mycgiscript.pl

.... or if you do not want to use Javascript, you might want to try this:

#!/usr/bin/perl

use strict;

print "Content-Type: text/html

<html><head><title>Time intensive task</title><head><body>
<h3><font size=6 color=red>This task will take a long long time...</font></h3>
Go have a cup of coffee while you're waiting.<p>
<h3>Please do not close or use this window while the task is in
progress.</h3>";
for my $ix(0..4000) { print " " } # fill the browser's buffer so that it will
be flushed
#
#
sleep(10); # do your processing...
#
#
print "<h2>DONE!</h2>Now you may use this window again.";

The above script will simply force the browser to flush its buffer so that the
user will not need to look at a blank screen.

Tom
ztml.com





Michael Budash 10-08-2003 03:21 PM

Re: Send two documents to browser? - repost
 
In article <45j7ovkt9uhjjpbs676sjr0s2suuqlg5g5@4ax.com>,
Mark <REMOVEXtwoheadsX@tiscaliX.co.uk> wrote:

> > Hi All,
> >
> > I have a commercial website search script which is slow in returning
> > its results. The consequence is that for a short period the screen is
> > white until the results are returned.
> >
> > Is there a simple way to make the script return a temporary document
> > to the browser which is then replaced by the search results?
> >

>
> Yes, there are simple ways to do this. However, they are no more
> Perl-specific than they are Cobol-specific. Rather than give you a
> whole
> solution here (and encourage more non-Perl-specific questions,
> drowning
> out those with Perl questions), I'll mention "interstitial pages",
> "browser redirects", and point you toward Google and the
> comp.infosystems.www.authoring.cgi newsgroup.


http://www.stonehenge.com/merlyn/Web...ues/col20.html

hth-

--
Michael Budash


All times are GMT. The time now is 06:50 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.