Crashthatch Posted June 12, 2007 Share Posted June 12, 2007 I have a script which takes up to 30 seconds to execute. The script generates an image. I need to send a message to the browser so that it thinks the page is complete within 10 seconds. Ideally, whenever the script starts to run, it'd output a message saying that the image will be created soon, and the browser would stop loading the page, then the script would go on to create the image (and obviously not output anything else to the browser). A bit more detail: I'm actually making a page which will be loaded through another website (Facebook). However that site will hit my script, then only wait 10 seconds for the page to finish loading. If my page takes longer than 10 seconds to load, Facebook times out and prints an error message (and anything that was sent from my page is ignored). So even though my page is only generating an image which isn't even used on that page, Facebook times out while waiting for my script to finish. Is there some kind of PHP function sendEndOfPage() or something which would stop it waiting, and just print "Your image will be created soon"? OR, a function like include() but which doesn't wait for the included page to finish- it just starts it and carries on. That way, the 1st script could call a 2nd script and then finish while the 2nd script does all the work behind the scenes. Any other solutions would be welcomed. Other than using cron (which would require quite a lot more work) I don't have any ideas. Thanks in Advance. Quote Link to comment https://forums.phpfreaks.com/topic/55185-sending-end-of-page-to-browser/ Share on other sites More sharing options...
DanDaBeginner Posted June 12, 2007 Share Posted June 12, 2007 not sure, but have you try using output buffering? Quote Link to comment https://forums.phpfreaks.com/topic/55185-sending-end-of-page-to-browser/#findComment-272938 Share on other sites More sharing options...
Crashthatch Posted June 12, 2007 Author Share Posted June 12, 2007 How would that help? That'd just save it to the end, then output it all then wouldn't it? I need to output a message, then continue to process, and not output anything else to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/55185-sending-end-of-page-to-browser/#findComment-273125 Share on other sites More sharing options...
kenrbnsn Posted June 12, 2007 Share Posted June 12, 2007 Since PHP executes on the server, it usually has to finish before sending it's output to the browser. You can try using the flush() function to flush the output, but some browsers don't show the partial output. You're best bet is to use AJAX and have Javascript put out the "Processing" message. Ken Quote Link to comment https://forums.phpfreaks.com/topic/55185-sending-end-of-page-to-browser/#findComment-273153 Share on other sites More sharing options...
Crashthatch Posted June 13, 2007 Author Share Posted June 13, 2007 Yeah, anything sent using flush() is ignored. Oh well, I'll try and find another way to do it. Thanks to you both anyway. Quote Link to comment https://forums.phpfreaks.com/topic/55185-sending-end-of-page-to-browser/#findComment-273581 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.