Q:

Do Ajax requests still finish when leaving the page?

I have a situation where I need to run some PHP, specifically where I need to send out a SOAP request and wait for the response, and then do something with that, however sometimes these requests can be slow and take up to 9 seconds.
Now I don't really want the user sitting there waiting 9 seconds for this to complete.
Basically the user flow is..

User comes to payment page
User clicks button to pay via payment gateway (Paypal)
User then returns to the site (SOAP request and all that need to be finished at this stage)

I was thinking of running it with the Paypal IPN notification but then didn't think it would be finished by the time the user got back to the site.
So, I'm wondering if I could send off a call when the user hits the first page via Ajax and have it run whilst the user is submitting payment and by the time they get back to the site it should be done -- it's not a big deal if they don't end up going through with payment, so I'm not worried about running this code before confirming payment.
My question is, if I fire this off to be run via AJAX, will the code still be executed if the user leaves the page before it has finished? If not, any ideas?

A:

Once a request is sent to the server, irrespective of whether you navigate away from the page the server side of the request will get completed.
The only thing that will not happen is the execution of client side callback method.

A:

If you are using php , there is  a php.ini setting  ignore_user_abort that tells php what to do when the client aborts the request. 
Its value is false by default. 
http://www.php.net/manual/en/misc.configuration.php#ini.ignore-user-abort

