为什么我在ajax尝试发布到服务器时验证网络错误?

时间:2017-07-26 10:31:47

标签: javascript asp.net-mvc

在asp.net mvc中尝试在服务器上调用控制器动作,为此目的写下这个ajax代码:

$('#enterbtn').click(function() {
                $.ajax({
                    url: '@Url.Action("UserValidation", "Account")',
                    type: 'POST',
                    data: {
                        phoneNumber: $('#PhoneNumber').val(),
                        Password:$('#Password').val(),
                    },
                    success: function () {
                        var url = '@Url.Action("LandingPage", "Home", new { area = "" })';
                        window.location.href = url;
                    },
                    error: function (jqXHR, exception) {
                        var msg = '';
                        if (jqXHR.status === 0) {
                            msg = 'Not connect.\n Verify Network.';
                        } else if (jqXHR.status == 404) {
                            msg = 'Requested page not found. [404]';
                        } else if (jqXHR.status == 500) {
                            msg = 'Internal Server Error [500].';
                        } else if (exception === 'parsererror') {
                            msg = 'Requested JSON parse failed.';
                        } else if (exception === 'timeout') {
                            msg = 'Time out error.';
                        } else if (exception === 'abort') {
                            msg = 'Ajax request aborted.';
                        } else {
                            msg = 'Uncaught Error.\n' + jqXHR.responseText;
                        }
                        alert(jqXHR.status);
                        alert(msg);
                    }
                });
            });


调试时,成功了解控制器调用,但是ajax得到这个错误:

  

验证网络   
  

会发生什么?如何解决?谢谢。

0 个答案:

没有答案
相关问题