Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jstree 3.0显示json_Javascript_Jquery_Json_Jstree - Fatal编程技术网

Javascript 使用jstree 3.0显示json

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'

我一直在尝试从apache加载一个json文件,并用jstree 3.0.0显示结果。 这是我的密码:

$(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" }
]