Javascript 使用jstree 3.0显示json
我一直在尝试从apache加载一个json文件,并用jstree 3.0.0显示结果。 这是我的密码:Javascript 使用jstree 3.0显示json,javascript,jquery,json,jstree,Javascript,Jquery,Json,Jstree,我一直在尝试从apache加载一个json文件,并用jstree 3.0.0显示结果。 这是我的密码: $(function () { $('#showTree').jstree({ 'core' : { 'data' : { 'url' : function (node) { return node= 'miley.json'
$(function () {
$('#showTree').jstree({
'core' : {
'data' : {
'url' : function (node) {
return node= 'miley.json';
},
'data' : function (node) {
return { 'id' : node.id };
}
}
}
});
});
认识麦莉:
[
{ "id" : "ajson1", "parent" : "national", "text" : "Simple root node" },
{ "id" : "ajson2", "parent" : "le", "text" : "Root node 2" },
{ "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" },
{ "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" },
]
我的控制台发誓它收到了json,但我对最终显示该树一无所知
我错过了什么?有人帮我吗?谢谢 jsTree插件的创建者Ivan Bozhanov在jsTree谷歌论坛上很快回答了我的问题。。。 这是我的工作代码:
$('#showTree').jstree({
'core' : {
'data' : {
'url': 'miley.json',
'data' : function (node) {
return { 'id' : node.id };
}
}
}
});
另外,我对麦莉做了一些更改,删除了我在上面发布的第一个miley.json中的最后一个逗号…:
[
{ "id" : "ajson1", "parent" : "#", "text" : "Simple root node" },
{ "id" : "ajson2", "parent" : "ajson1", "text" : "Root node 2" },
{ "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" },
{ "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" }
]