I have a form with URL:
localhost:83/mysite/item/UpdateItems/225
I have a temporary table in which I have loaded data and display in my form from temporary table.
When I refresh the page I don't want to fire an ajax call and truncate the table. But if I click on another link from menu then I do want to fire the ajax call and truncate tables.
Is it possible?
I have used beforeunload
for truncate table when click on another menu:
$(window).on('beforeunload', function(){
//My ajax code for truncate table
});
But this works on page refresh also, which I don't want. So I tried with matching string in URL:
$(window).on('beforeunload', function(e){
if (document.URL.indexOf("UpdateItems") > -1) {
console.log("page refresh");
}else{
console.log("not refreshed");
}
});
But this always go in first page refresh condition even if I have clicked on another menu.