These are chat archives for airbnb/javascript

7th
Apr 2017
riksnelders
@riksnelders
Apr 07 2017 12:14
Hey guys, Looking for a way to send data to backend onclose of tab or window. Now i need this to be cross browser compatible.. Any suggestions?
samundra kc
@samundrakhatri
Apr 07 2017 12:20
window.onbeforeunload = function () { return "Do you really want to close?"; };
riksnelders
@riksnelders
Apr 07 2017 12:21
Nop, have to run ajax call and = async. either crashes the window or im not sure if data is sent
sendBeacon is not supported to most browsers yet.. so not sure if i should use that..
Websockets might be a solution
samundra kc
@samundrakhatri
Apr 07 2017 12:22
socket will be good if you want instant
riksnelders
@riksnelders
Apr 07 2017 12:22
Dont really want it intstant, but neither do i want a settimeout running thats spamming ajax req.s
samundra kc
@samundrakhatri
Apr 07 2017 12:23
socket may help you.. but i dont think someone will add socket just to know when user is gone
Maybe that ll work.. if not supported, then just run interval ajax?