I have functionality in which I need to make a ajax call to update the database value before closing the browser using 'X' button of browser. I have used below code in the header of associated file:
$(document).ready(function() {
window.onbeforeunload = function(){
$.ajax('<?php echo base_url();?>index.php/ajax/myfunction?a=4');
}
});
On closing the browser the function works but ajax call is not executed..
What's the solution?