Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call URL before closing of Browser Window [duplicate]

I want to call an URL in the unload-Function of a Webpage but in the unload-function the get request is not working. My code looks like this:

$(window).unload( function () { 
   jQuery.get("someurl")
} );

We want to be informed about the closing of the window for some logging of user actions. Is it possible somehow?

If i add an alert() after the jQuery.get(), the Get-Request has enough Time, to do this, but that's not what we prefer.

like image 838
bitboxer Avatar asked Dec 05 '22 06:12

bitboxer


1 Answers

Use:-

jQuery.ajax({url:"someurl", async:false})
like image 57
AnthonyWJones Avatar answered Dec 08 '22 14:12

AnthonyWJones