ASP .NET MVC issue with Ajax.BeginForm replaces all view content with JSON data

后端 未结 2 555
无人及你
无人及你 2021-01-25 21:39

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

相关标签:
2条回答
  • 2021-01-25 22:12

    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

    0 讨论(0)
  • 2021-01-25 22:22

    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

    0 讨论(0)
提交回复
热议问题