MozillaZine

sendBeacon not working on window close

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
mahks

User avatar
 
Posts: 31
Joined: September 9th, 2009, 5:08 pm

Post Posted October 17th, 2015, 10:41 pm

Trying to get navigator.sendBeacon to work from onbeforeunload.

This is what I have found:
Works as expected if the page is in a tab and that is closed.
If the whole window is closed PHP does not receive the request and I cannot confirm if the browser sent it as the window is closed (no persistent logs)
If I place a synchronous XMLHttpRequest in the event, then the sendBeacon works as expected.

It is my understanding that since synchronous XMLHttpRequests are depreciated, we must now use sendBeacon to send data from onbeforeunload as
asynchronous XMLHttpRequests do not work in that event.

Is anyone using sendBeacon in onbeforeunload successfully?
Last edited by mahks on October 18th, 2015, 3:34 pm, edited 1 time in total.
Ignorance is being uninformed, persisting once informed is being ignorant.

DanRaisch
Moderator

User avatar
 
Posts: 117965
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted October 18th, 2015, 4:30 am

Moving to Web Development.

Return to Web Development / Standards Evangelism


Who is online

Users browsing this forum: No registered users and 1 guest