开发者

Long Polling causes problems when user exits page

开发者 https://www.devze.com 2023-02-04 03:17 出处:网络
My Long Polling system runs using PHP and jQuery but I have encountered a problem when 开发者_Python百科developing it.

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消