Need to redirect to page when value is true based on ajax call. The issue is that the page is redirected if either true or false is returned.
<a class="btn btn-warning" onclick="return clickthis(25007); " href="test.aspx?id=eheAhgpAS38=">Start </a>
function clickthis(obj) {
var bValid = false;
function ajax1() {
return $.ajax({
type: "POST",
url: "order.aspx/ActivateLocation",
data: '{id:' + obj + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(r) {
if (r.d == "1") {
bValid = true;
} else {
$('#overlay').remove();
$.growl.error({
title: "Error",
message: "An error occurred, Please try again."
});
bValid = false;
}
}
});
}
$.when(ajax1()).done(function(a1) {
return bValid;
});
}