SharkBait Posted May 17, 2007 Share Posted May 17, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/51884-processing-page/ Share on other sites More sharing options...
roopurt18 Posted May 17, 2007 Share Posted May 17, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-255814 Share on other sites More sharing options...
SharkBait Posted May 17, 2007 Author Share Posted May 17, 2007 and what would the old fashion way be? Quote Link to comment https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-255821 Share on other sites More sharing options...
448191 Posted May 17, 2007 Share Posted May 17, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-255871 Share on other sites More sharing options...
SharkBait Posted May 17, 2007 Author Share Posted May 17, 2007 I wouldn't even know where to start. I've ajax once to pull mysql data without refreshing the page at a certain interval, but thats it. Quote Link to comment https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-255922 Share on other sites More sharing options...
448191 Posted May 18, 2007 Share Posted May 18, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-256096 Share on other sites More sharing options...
johnrcornell Posted May 19, 2007 Share Posted May 19, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51884-processing-page/#findComment-256746 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.