1

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 Answers1

3

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.

Community
  • 1
  • 1
wolfgangwalther
  • 1,226
  • 7
  • 15