I want to update a database(Sqlserver 2008) on browser close.
I have a table in which i have value 0, I want that 0 should be updated to 1 whenever user closes the browser. How can i do this?.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gohil JayendrasinhPosted Jun 30, 2012, 7:09 AM
try it it's working
var preventUnloadPrompt;
var messageBeforeUnload = "my message here - Are you sure you want to leave this page?";
$('a').live('click', function () { preventUnloadPrompt = true; });
$('form').live('submit', function () { preventUnloadPrompt = true; });
$(window).bind("beforeunload", function (e) {
var rval;
if (preventUnloadPrompt) {
return;
} else {
//location.replace(redirectAfterPrompt);
return messageBeforeUnload;
}
return rval;
})
call ajax method and update your records.
Kunal VaishyaPosted Jun 30, 2012, 4:27 AM
this