0
votes

When running the following jsp code, all I get is "loading..." and nothing happens. This is my first time using ajax with Fancytree. I tried a number of variations, even adding the ajax commented-out line, but no luck. I am using jquery-1.9.1 and Fancytree 2.0.

$("#tree").fancytree({
  ...
  //ajax: { type: "POST", contentType: "application/json" },
  source: {
    url: "getTreeData.jsp",
    cache: false
  },
  ...
});

The output from getTreeData.jsp

[{title: 'First', key: '153', folder: false, id: '4', content: 'ABCDEFG'}]
1
Are you returning Content-type: application/json as a http header of getTreeData.jsp? What about if you set that array directly on the source property, does it work then? - Dominic
Does your getTreeData.jsp have a parent parameter and does it allow HttpGet? - Jane S
That output is not a valid JSON (if the response from getTreeData.jsp is exactly like you put in the question). Needs double colon on keys and values that are string: [{"title":"First","key":"153","folder":false,"id":4,"content":"ABCDEFG"}] - RaphaelDDL
One of the things i tried was p pasted the jsp output directly into the source, so I think the json string is ok. - Dave
I tried using double quotes around strings -- and it worked!!! Thank you all. - Dave

1 Answers

2
votes

That output is not a valid JSON (if the response from getTreeData.jsp is exactly like you put in the question).

Needs double colon on keys and values that are string, like the following:

[{"title":"First","key":"153","folder":false,"id":4,"content":"ABCDEFG"}]