Long Polling causes problems when user exits page
My Long Polling system runs using PHP and jQuery but I have encountered a problem when 开发者_Python百科developing it.
When the user exits the page it seems to like 'jam' and the AJAX request seems to remain and won't exit.
Anyone know how to prevent / overcome this?
Is this server side or client side?
Client side, you can abort() the outstanding XMLHttpRequest.
Server side, you can introduce a timeout, and raise an exception or signal when it expires. Look into the pcntl_alarm() call, which raises the SIGALRM signal (check pcntl_signal() for how to catch this).
精彩评论