Reputation: 219
Here I have script which will run if anyone try to refresh page, but after my ajax success response I want this script should not work or get removed. How to do this?
Script which need to be removed
$(window).on('beforeunload', function() {
return $(".clk_mdl2").click();
});
This is ajax which will get all data after this above mentioned script should be removed automatically.
$.ajax({
url: "<?= base_url('Users/get_data') ?>",
type: "POST",
data: {
id: id
},
success: function(data) {
if (data === ok) {
//remove above onbeforeunload script
}
}
});
Upvotes: 1
Views: 178