I have created a sample ASP.NET MVC website in VS 2015 and in a view i am using the extension Ajax.BeginForm to post login credentials to controller, and on OnSuccess callback i
If you're sending some status code different than 200 from server side, the error callback is executed:
$.ajax({
url: '/foo',
success: function(result) {
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert('you will see this');
}
});
check this link out https://stackoverflow.com/a/4707762/3521012
If your displaying only the json returned by your LogIn()
method, then its because you have not included jquery.unobtrusive-ajax.js
file in your view. As a result, Ajax.BeginForm()
falls back to making a normal submit