I am unable to load JSON from a file. I have taken the 05_tree_checkboxes.html sample and modified it to try to use JSON for the first tree. My HTML file is attached, but here is the relevant script that tries to load the JSON into my tree:
tree = new dhtmlXTreeObject(“treeboxbox_tree”, “100%”, “100%”, 0);
tree.setSkin(‘dhx_skyblue’);
tree.setImagePath(“codebase/imgs/csh_bluebooks/”);
tree.enableCheckBoxes(1);
tree.setXMLAutoLoading(“common/test.json”);
tree.setDataMode(“json”);
tree.loadJSON(“common/test.json?id=0”);
My JSON is in the file common/test.json and has the following content:
{
“id” : “0”,
“text” : “Test”
}
When I load my page I get an error dialog when trying to load the JSON file. The error is:
LoadXML
Description: Incorrect JSON
I can’t figure out why this won’t load. I did make a local change to the LoadJSON routine to see if I could get more information from the exception that is raised. What I got back was HTML including:
HTTP Status 404 - Not Found
Status report
message - Not Found
description - The requested resource is not available.
I’m not sure if this helps or not. The file is definitely there, and has appropriate permissions.
Oh, i really sory that didn’t find your wrong json in a big part of the text…
You have not right syntax:
{
“id” : “0”,
“text” : “Test”
}
You need the next:
{id:'0', item:[
{id: 'item1', text: 'Test'}
]}
The root is can’t have a text.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan