【发布时间】:2013-07-19 10:48:49
【问题描述】:
我使用 JSTree 插件来显示部门限制。 服务器端(asp.net 3.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 字符串的节点。
JSON-string,webmethod返回的是:
{
'data': 'department001',
'attr': {
'id': 'nodeid1773'
},
'children': [
]
},
{
'data': 'department001',
'attr': {
'id': 'nodeid1779'
},
'children': [
]
}
如果我将此字符串复制粘贴到:
"json_data": {"data" : [...] }
我得到正确的结果。 请帮忙,不明白我在做什么错。
【问题讨论】:
标签: jquery asp.net json jstree