Send two documents to browser? - repost

Discussion in 'Perl Misc' started by Mark, Oct 8, 2003.

  1. Mark

    Mark Guest

    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.
    Mark, Oct 8, 2003
    #1
    1. Advertising

  2. 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
    Gregory Toomey, Oct 8, 2003
    #2
    1. Advertising

  3. Mark

    tom Guest

    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
    tom, Oct 8, 2003
    #3
  4. In article <>,
    Mark <> 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/WebTechniques/col20.html

    hth-

    --
    Michael Budash
    Michael Budash, Oct 8, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith-Earl
    Replies:
    1
    Views:
    413
    Alvin Bruney [MVP]
    May 3, 2004
  2. Gwayn
    Replies:
    0
    Views:
    345
    Gwayn
    Jan 31, 2006
  3. Amil Hanish
    Replies:
    0
    Views:
    312
    Amil Hanish
    Jul 26, 2006
  4. Replies:
    1
    Views:
    477
    Juan T. Llibre
    Oct 18, 2006
  5. Mark

    Send two documents to browser?

    Mark, Oct 3, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    92
    J├╝rgen Exner
    Oct 3, 2003
Loading...

Share This Page