Error from ajax request (YUI) if it is still executing when the user leaves the page

295 Views Asked by At

My application is developed in PHP and Symfony, and it's running on a standard apache2 configuration.

The problem arises when I try to leave a page while an ajax request is still executing. The script stops and returns a 500 error code. That happens with every ajax request regardless of what it does internally.

Is it the expected behavior?

I've tried out setting ignore_user_abort to true but it didn't seem to work.

1

There are 1 best solutions below

0
mcubik On

My bad: I rushed. Not enough investigation prior to the question and not enough information in the post itself. Anyway, your comments guided me towards the solution.

I'm using YUI Connection Manager for ajax requests. As Maerly suggested, it wasn't really a 500 error but the browser aborting the request, which in Chrome console looks like the former. On page leave, YUI invokes the failure callback with status=0 and statusText="communication failure", so I fixed it by ignoring that case.

Thank you