I'm creating a analytics system where I need to send the page read time in seconds with a jquery ajax call on page unload. But the AJAX call is not working on page unload (it's working on load, click etc).
Browser: Chrome 104 Android
My JavaScript:
document.addEventListener('beforeunload', function() {
$.ajax({
type: "POST",
url: '', /* Current Page */
data: {
report: 120 /* Just Example */
},
cache:false,
async: false
});
});