in reply to Sending html content to the browser as the script runs

Read up on NPH scripts.

Update:

While NPH would do what you said in the subject (unless the browser waits for the whole page to be received before rendering the page), it's not well suited to provide a "Please Wait" screen. Specifically, it doesn't allow you to remove any "Please Wait" messages you have sent* (without using ill-supported Server Pushes).

What you want to do is usually done as follows:

  1. Start an external process to perform the requested task. (Alternatively, you can send the request to an existing process.)
  2. Give a please wait response to the client, and have the client Refresh itself after a time interval.
  3. When the client refresh itself, check if the task is done. If the task is not done, repeat the last step.
  4. Display the result.

Instead of using the HTTP Refresh header, you can use any of Java, Flash or JavaScript (AJAX) to check whether the task has been completed or not. I wouldn't use them.

Update:

* – I suppose you could send JavaScript which modifies the document being viewed.

  • Comment on Re: Sending html content to the browser as the script runs

Replies are listed 'Best First'.
Re^2: Sending html content to the browser as the script runs
by jhourcle (Prior) on Aug 03, 2006 at 12:06 UTC
    ... it's not well suited to provide a "Please Wait" screen. Specifically, it doesn't allow you to remove any "Please Wait" messages you have sent* (without using ill-supported Server Pushes).

    I'll be the first to admit that server-push isn't well supported in most browsers, however, for any CSS aware browser, if they have javascript turned on, you can get around the problem.

    Basically, you do the following logic:

    print a block of text in a named div loop: (wait) emit javascript to set the last named div to 'hidden' print the next block of text in a named div (repeat the loop)

    I'll admit, it's not the most friendly way of doing things, but it doesn't require java or flash to be installed, and it will still get to the results (although, leave other stuff on the screen), even if the javascript isn't turned on. (assuming you don't load the text to come up in a hidden element, and then use javascript to unhide it as to hide the otherone)