Jquery jsTree JSON解析问题

Jquery jsTree JSON解析问题,jquery,asp.net,json,jstree,Jquery,Asp.net,Json,Jstree,我使用JSTree插件来显示部门结构。 服务器端(asp.NET3.5)运行良好,我得到了JSON对象 但当我尝试时: $(document).ready(function () { $('#btntst').click(function () { $('#mainDiv').html('wait for data'); $.ajax({ type: 'POST', url: '_layouts/GridVi

我使用JSTree插件来显示部门结构。 服务器端(asp.NET3.5)运行良好,我得到了JSON对象

但当我尝试时:

$(document).ready(function () {
    $('#btntst').click(function () {
        $('#mainDiv').html('wait for data');
        $.ajax({
            type: 'POST',
            url: '_layouts/GridView/ApplicationPage1.aspx/getTable',
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            data: "{}",
            success: function (msg) {
                $('#jsTreeContainer').jstree({
                    "json_data": {
                        "data": [msg.d]
                    }
                    , "plugins": ["themes", "json_data"]
                });
            }
            , timeout: 60000
        });
    });

});
我只得到一个包含所有JSON字符串的节点。
webmethod返回的JSON字符串为:

{
  'data': 'department001',
  'attr': {
    'id': 'nodeid1773'
  },
  'children': [

  ]
},
{
  'data': 'department001',
  'attr': {
    'id': 'nodeid1779'
  },
  'children': [

  ]
}
如果复制此字符串,请将其粘贴到:

"json_data": {"data" : [...] }
我得到了正确的结果。
请提供帮助,无法了解我做错了什么。

您的脚本正在查找类型为
JSON\u data
的JSON对象,但正常响应仅为
data
。查看这些更改是否有效:

$(document).ready(function () {
    $('#btntst').click(function () {
        $('#mainDiv').html('wait for data');
        $.ajax({
            type: 'POST',
            url: '_layouts/GridView/ApplicationPage1.aspx/getTable',
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            data: "{}",
            success: function (msg) {
                $('#jsTreeContainer').jstree({
                    "json_data": [msg.d],
                    "plugins": ["themes", "json_data"]
                });
            }
            , timeout: 60000
        });
    });

});

我得到错误:未捕获异常:既没有提供数据也没有提供ajax设置。在我的萤火虫里。但是你的建议给了我正确的方向:“json_数据”:{“数据”:[json.parse(msg.d)]},