I have tried for "unload" and "beforeunload" binding in following
code, but none of the browser, except FF, is sending a request to
node.js:
$(window).bind('unload', function(){
$.ajax({cache: false,
dataType: "script",
async: false,
url: "http://node.example.com/unsubscribe"
});
});
Any suggestion, how to notify node.js that user is leaving the page?
Thank you,
Sunil Khedar
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
Add a listener for the 'close' event on request.connection?
(new Image()).src = "node.example.com/die"
> --
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en.
>
>
--
Sent from my mobile device
Aaron
In my experience onbeforeunload with a jQuery ajax request works most
of the time in IE7 (not tested other IEs), Firefox and Chrome, it
doesn't always work though.
My suggestion would be to handle this on the server if possible.
Good luck :)
You don't need to stop the event for the ajax request to fire.
Does the current page maintain a comet-like connection to the server? If so, then when the browser leaves the page it is going to cleanly shut down the connection (hopefully, otherwise you have to wait 30 secs for a timeout) which will be marked by a close event at the TCP level, rather than the HTTP level. Ryan has already mentioned this; what you're trying trying to do is more complicated and less reliable.
On Apr 13, 2010 8:47 AM, "Miguel Cavaco Coquet" <mco...@gmail.com> wrote:
as long as it gets executed quickly, your right :) If its buried in code, it might not. It should work, but its rather flaky.
On 2010/04/13, at 13:34, Connor Dunn wrote:
>> I cant be 100% sure now, but if i recall correctly...