Javascript json响应中的modelErrors属性未定义

Javascript json响应中的modelErrors属性未定义,javascript,jquery,json,ajax,asp.net-ajax,Javascript,Jquery,Json,Ajax,Asp.net Ajax,我正在尝试解析json响应。JSON响应来自responseText属性 首先,我从Json得到如下响应: {"Success":false,"Error":true,"ErrorType":1,"ModelErrors":{"Name":"\u0027Name\u0027 must not be empty.","Owner":"\u0027Owner\u0027 must not be empty.","Email":"\u0027Email\u0027 must not be empty.

我正在尝试解析json响应。JSON响应来自responseText属性 首先,我从Json得到如下响应:

{"Success":false,"Error":true,"ErrorType":1,"ModelErrors":{"Name":"\u0027Name\u0027 must not be empty.","Owner":"\u0027Owner\u0027 must not be empty.","Email":"\u0027Email\u0027 must not be empty.","Password":"\u0027Password\u0027 must not be empty.","Size":"Please provide a valid Number"}}
当我执行
console.log(response.responseText)
时,我会在控制台上获得上述输出

现在我在这个函数中捕捉到这个响应。一切顺利,但当错误块在发生错误的情况下执行时,我会得到未定义的ModelErrors属性。这是我的功能

 $("form").on('submit', function () {
        var form = $('.form');


        var url = form.attr('action');
        var formData = form.serialize();
        $.ajax({
            type: 'POST',
            url: url,
            dataType: 'json',
            data: formData,
            success: function (response) {


                if (response.Success==true) {
                    console.log(response.Success);

                    showMsg(response.Message);
                    //alert(response.Message);
                }

                //alert(data);
            },
            error: function (response) {

                console.log(response.responseText);

                if (response.responseText.Error === true)

                {

                    var modelErrors = response.responseText.ModelErrors;

                    console.log(modelErrors);
                    console.log("Check "+modelErrors);

                }

            },

            cache: false
        });
    });
我尝试了不同的解决方案,但我不知道哪里做错了。请在这方面帮助我。谢谢

您可以解析JSON
var json='{“Success”:false,“Error”:true,“ErrorType”:1,“ModelErrors”:{“Name”:“\u0027Name\u0027不得为空。”,“Owner”:“\u0027Owner\u0027不得为空。”,“Email”:“\u0027Email\u0027不得为空。”,“Password”:“\u0027Password\u0027不得为空。”,“Size”:“请提供有效数字”}};
var tmp=JSON.parse(JSON);

log(tmp.ModelErrors)可能在
\u0027Name\u0027
中发布。从您的
模型错误中删除
\u0027
,然后重试。