我编写了以下代码,显示错误:
Cannot read property 'children' of null
我希望在单击节点时加载子项。
request:function(nodeId, level, onComplete)
{
alert(nodeId+'p '+level+' p '+onComplete);
var i=0;
$.ajax({
url: '/users/userhierarchy.json?id=' + nodeId,
dataType: 'json',
success: function(json){
var tree = json;
var subtree = $jit.json.getSubtree(tree, nodeId);
$jit.json.prune(subtree, level);
i++;
ans= {
'id': nodeId,
'children': subtree.children
};
onComplete.onComplete(nodeId, ans);
},
});
}