Re: pulling script in interval of second.
| From: | Tim Streater | Date: | Tue, 01 Jul 2014 21:44:00 +0000 |
| Subject: | Re: pulling script in interval of second. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-323582@lists.php.net to get a copy of this message | ||
On 01 Jul 2014 at 22:10, Stuart Dallas <stuart@3ft9.com> wrote:
> On 1 July 2014 22:02, Tim Streater <tim@clothears.org.uk> wrote:
>
>> On 01 Jul 2014 at 21:31, hadi <almarzuki2011@hotmail.com> wrote:
>>
>>> I already tried onbeforeunload and unload event. But the problem when
>> user
>>> change the page or navigate to different page code will be executed.
>>
>> In your onbeforeunload event handler, you should make a synchronous ajax
>> request to your PHP script (or another script). If you do an asynchronous
>> ajax request, the page unloads and apache will kill the PHP script. With a
>> synchronous request, the page stays until the PHP script completes.
>
> That's not his issue; he's already got that covered - see the code he's
> previously posted to the list. He's talking about internal links within the
> site also triggering the onbeforeunload as well as external links.
Well, you have to consider how to organise/design your site or application, then. That is
fundamental to programming. We shouldn't be doing that for people, we should suggest
tools/methods that they may have overlooked. After that it's up to them.
--
Cheers -- Tim