Jquery 来自django的jstree动态JSON数据

Jquery 来自django的jstree动态JSON数据,jquery,django,json,jstree,Jquery,Django,Json,Jstree,我正在尝试设置jsTree来动态地接受来自django的JSON数据 这是我让django返回jstree的测试数据: result=[{ "data" : "A node", "children" : [ { "data" : "Only child", "state" : "closed" } ], "state" : "open" },"Ajax node"] response=HttpResponse(content=result,mimetype="application/json")

我正在尝试设置jsTree来动态地接受来自django的JSON数据

这是我让django返回jstree的测试数据:

result=[{ "data" : "A node", "children" : [ { "data" : "Only child", "state" : "closed" } ], "state" : "open" },"Ajax node"]
response=HttpResponse(content=result,mimetype="application/json")
这是我正在使用的jstree代码:

jQuery("#demo1").jstree({   
           "json_data" : {  
             "ajax" : {  
                "url" : "/dirlist",  
                "data" : function (n) {   
                    return { id : n.attr ? n.attr("id") : 0 };   
                },
                 error: function(e){alert(e);}
             }  
         },  
        "plugins" : [ "themes","json_data"]
     });
我得到的只是ajax加载符号,ajax错误响应也会被触发,并发出未定义的警报。我也尝试过在django中使用simpleJson编码,但结果相同

如果我更改url,使其接收到一个包含相同数据的JSON文件,它将按预期工作


关于这个问题有什么想法吗?

问题似乎是我在包含application/JSON mimetype时没有同时进行simplejson编码


全部排序。

问题似乎是我在包含应用程序/JSON mimetype时没有同时进行simplejson编码

都分类好了