I'm sending ajax request on my BeginForm's onBegin function and I want to stop next steps when data.success
is false.
But returning false, from success
method not returning it from onBegin
. How to make this asynchronous thing work? I want to stop all the cycle in onBegin function if data.success
is false.
function onBegin() {
$("#spMessage").html("Processing...");
$.ajax({
url: '@Url.Action("test")',
type: "POST"
success: function (data) {
if (!data.success) {
alert("Sorry!");
/*Here I want to return false not from success function, but from OnBegin function*/
return false;
}
}
});
}