views:

273

answers:

3

I have a script that takes a while.

I'd like to display a page during the processing of the script then redirect when the process is complete.

E.g.: form.php -> processing.php -> display_result.php

I would like that processing.php is displayed immediately after form is submitted showing (Processing your information, please wait...)

Once processing is complete the page should be redirected to display_result.php

Is there anyway to sort of flush the content to the browser before processing begins, then redirect when the process is complete?

A: 

you can do this in a simple way.

once you submit the form, your processing starts in the server side.

redirect the user to processing.php with a simple meta tag refresh content with some seconds redirecting to the same processing.php.

e.g <meta http-equiv="refresh" content="600">

processing.php should have server side script logic that checks whether your processing is complete. if complete, redirect user to display_result.php.

coder
+1  A: 

That sounds like a Javascript/Ajax task.

Ajax calls are asynchronous, and this makes them ideal for what you are trying to achieve.

You send the form content through an ajax request and then manipulate the DOM of the page to show something like a loading bar while the request is taking place. When the request finishes you can then manipulate the DOM again to show the result of the form processing, or redirect to a new page with that info.

rogeriopvl
A: 

You should use Ajax for this task.

<div class="trigger">Trigger</div>
<div class="result"></div>
<div class="log"></div>

$('.log').ajaxStart(function() {
  $(this).text('Please wait...');
});

Reference
http://api.jquery.com/ajaxStart/

JeremySpouken