3

I have written the following code which shows the error:

Cannot read property 'children' of null

I want the children to be loaded when the node is clicked.

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);

                    },

                });

            }
ankitr
  • 5,992
  • 7
  • 47
  • 66
Mohammad Sadiq Shaikh
  • 3,160
  • 9
  • 35
  • 54

0 Answers0