Jump to content

Recommended Posts

I am in need figuring out how to make a processing page with PHP.

 

You know the onces that say: Please wait while we process your order.....

 

Now what my script does it it sends of a cURL request.. and I need to have a screen showing that the order is being processed.

 

Would I use like while loop or something and wait for the return request??

 

Hopefully this make somewhat sense!

Link to comment
https://forums.phpfreaks.com/topic/51884-processing-page/
Share on other sites

PHP runs on the server and doesn't output anything until the script is finished, so sticking a while loop in a PHP script will not help you with your goal.  (That statement is 99% true, btw).

 

I would set the processing page up as a simple animated .gif so the user feels that something is happening.  The page itself should invoke AJAX requests via a timer.  The requests should return a simple 0 or 1 if the request has finished; your AJAX handler can redirect to the final confirmation page when it has received a 1 from the server.

 

Of course, once you go this route, you have to make sure the user's browser supports AJAX.  If it doesn't, you need to do it the old fashioned method, so to speak.

Link to comment
https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-255814
Share on other sites

If you're going to employ Ajax you might as well do it proper and use it to fetch progress data.

 

If the browser doesn't support Ajax I would suggest using an IFRAME, and if even that isn't supported you can use a dummy like an animated gif and fork the actual processing.

Link to comment
https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-255871
Share on other sites

Like with forking, you'd have to separate display from processing. Also you'd have to break down the processing in individual steps or anything  else that indicates progress in the transaction. The simplest way would be for the javascript on the client to first call the processing script, then fetch progress data from an XML file at set intervals 500ms or a second or whatever. The processing script writes information about it's progress to this XML file, the client script fetches it and uses it to display a visual representation of the progress.

 

Example:

 

<response>
   <progress>
      <total_steps value="10"/>
      <current_step value="3"/>
   </progress>
</reponse>

 

Note that for something non-hierarchal like this you're probably better off using JSON.

 

Anyway, with information like this, the client javascript can make an assessment in the line off; ok, so I have a 100px width statusbar, so I now need to display (100/10)*3 = 30px of it in green. When the total steps equals the current step, it will know it is time to redirect. Just a simple example but you get the idea.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-256096
Share on other sites

I admit that I was too lazy to read the entire thread, so I hope my answer is appropriate-

 

Use the Yahoo! UI library if production time is an issue. For your specific issue, here's the code:

 

http://developer.yahoo.com/yui/examples/container/panelwait/1.html

 

and here's an example of the implementation:

 

http://developer.yahoo.com/yui/examples/container/panelwait/2.html

Link to comment
https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-256746
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.