Try to change like below, because you are using jquery-3
$(window).on("unload", function() {
alert("call");
console.log("this will be triggered");
});
Try to change like below, because you are using jquery-3
$(window).on("unload", function() {
alert("call");
console.log("this will be triggered");
});