I am working on the php to generate few files using ajax requests and my doubt is that will the response once sent will not complete all its action if the browser is closed?
1 Answers
When you close your browser or hit the cancel button, the connection to the webserver is terminated. Whether your server-side php script will continue with execution, depends on the PHP/Apache configuration.
Default configuration is to terminate the execution of the PHP script, as soon as the connection is cancelled. However, you can change this default setting to continue execution!
To do this, please use the ignore_user_abort
function:
http://php.net/manual/en/function.ignore-user-abort.php
You can read more about the topic here:
http://php.net/manual/en/features.connection-handling.php
There's some more discussion about that here as well:
PHP auto-kill a script if the HTTP request is cancelled/closed
Addition: Just in case, that I am misunderstanding your question: When closing the browser your Javascript code on the client side will of course NOT continue with execution after the PHP script finished.

- 1
- 1

- 1,226
- 7
- 15
-
Tried to clarify it a little bit more and updated the answer. – wolfgangwalther Oct 31 '14 at 07:35
-
@LifeHacker Are you still missing something in my answer? – wolfgangwalther Oct 31 '14 at 08:36
-
Seems Like I got 50% of the answer. will give a try – Jenno Richi Benat Oct 31 '14 at 09:13
-
So what's the other 50% then? Please clarify your question, if you want to now more! :) – wolfgangwalther Nov 02 '14 at 23:04