I am newbie in JS. I am trying to use jsTree with json and ajax.
I see a json request in chrome for .....&id=# (actualy in encoded form ....&id=%23) which returns following result:
[{"id":"root_42","parent":"#","text":"Structure","state":{"opened":true},"children":[{"id":"1","parent":"root_42","text":"a new docset","state":{"opened":true}}]}]
but the tree still showing the loading state and i see error in Chrome:
Uncaught TypeError: Cannot read property 'id' of undefined
self.onmessage = function (data, undefined) {
if(data.data) { data = data.data; }
var dat = data.dat,
par = data.par,
chd = [],
dpc = [],
add = [],
df = data.df,
t_id = data.t_id,
t_cnt = data.t_cnt,
m = data.m,
p = m[par],
sel = data.sel,
tmp, i, j, rslt,
parse_flat = function (d, p, ps) {
if(!ps) { ps = []; }
else { ps = ps.concat(); }
if(p) { ps.unshift(p); }
the error occurs here --->>>>> var tid = d.id.toString(),
i, j, c, e,
tmp = {
id : tid,
text : d.text || '',
..........
I understand that is something wrong with passing 'children' through the code, but i compare the passed json with the examples on the site www.jstree.com and i can't see mistakes.
Please, could you check what's wrong. More thanks!