开发者

Display processing page then redirect when complete

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 r开发者_开发技巧edirect when the process is complete?


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.


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.


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜