Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/55185-sending-end-of-page-to-browser/
Share on other sites

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

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.