The best solution is to use navigator.sendBeacon . This is a completely new functionality that is starting to be implemented in new versions of browsers. The feature is available in browsers newer than Chrome 39 and Firefox 31. It is not supported by Internet Explorer and Safari at the time of writing. To make sure your request is sent in browsers that do not yet support the new functionality, you can use this solution:
var navigator.sendBeacon = navigator.sendBeacon || function (url, data) { var client = new XMLHttpRequest(); client.open("POST", url, false);
This function does not allow you to register an onsuccess callback.
user1319331 May 19 '15 at 12:58 2015-05-19 12:58
source share