I just want to check condition within beforeunload event like other guy ask.My Code is here=>
$(window).bind('beforeunload', function (e) {
if (CheckCondition())
return "Are you sure to go?";
});
function CheckCondition()
{
$.ajax({
url: '/Field/CheckBeforeChangeURL',
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
//Bool value return from server side
return r;
},
async: true,
processData: false,
cache: false
});
}
It still go without asking.I already try this beforeunload ignore condition but still not working.