in reply to Let users wait for the results

In addition to the answer given by screamingeagle above, you may want to look at the column by merlyn which discusses a slightly more advanced variation of this technique.

 

perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'

Replies are listed 'Best First'.
Re: Re: Let users wait for the results
by dreadpiratepeter (Priest) on Feb 02, 2002 at 15:09 UTC
    screamingeagle's response will only work if it is the building of the output that takes the time. Obviously, if it is a lengthy calculation followed by a quick display, nothing will be gained.
    The method in the column is interesting, but maybe a little clunky for the user. (Either having to repeatedly reload, or wait for the auto-reload to realize its done).
    If you want to get really fancy, you can try this:
    page1 contains a hidden IFRAME (in I.E.) or FRAME (in Netscape) called hidden. You can detect the broswer in a bit of javascript at the bottom of your page and do a document.write of the appropriate container.
    when the user submits the query, an onSubmit handler shunts the request to the hidden frame. I'm going to assume I.E. here, the code is similar for netscape:
    document.all.hidden.src="calculation.html?...";

    Then the handler exposes a hidden DIV (or ILAYER in netscape) containing the hold on message:
    document.all.message.style.visibility='visible';

    The handler returns false so that the page remains up. (You could also disable the submit button in here to prevent the user from repeatedly submitting the form while she's waiting).
    return false;

    The calculation script returns an empty page with an onload handler that redirects the top page to the results.
    onLoad="top.document.location.href='results.html?...'

    This assumes that the results are cached in a file or a session variable, or are simple enough to be passed through the request parameters.

    All this is probably too complicated and too much effort to be of value, but it is an option. I've had to use it in the past.
    Also, the flexibility of having a hidden communication channel in your web app comes in handy all over the place. The hidden frame can be used to silently update the server while the client is working. It can be used to log javascript errors in your server-side log files.

    -pete
    Entropy is not what is used to be.