I'm trying to set up jsTree to dynamically accept JSON data from django.
This is the test data i have django returning to jstree:
result=[{ "data" : "A node", "children" : [ { "data" : "Only child", "state" : "closed" } ], "state" : "open" },"Ajax node"]
response=HttpResponse(content=result,mimetype="application/json")
this is the jstree code I'm using:
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"]
});
All I get is the ajax loading symbol, the ajax error response is also triggered and it alerts "undefined". I've also tried simpleJson encoding in django but with the same result.
If I change the url so that it is receiving a JSON file with identical data, it works as expected.
Any ideas on what the issue might be?