 $(function () {     $.ajax({         type: "POST",         url: "Default.aspx/Hello",         data: "{}",         contentType: "application/json; charset=utf-0",         dataType: "json",         success: function (data)         {             var Details = data.d;                       if (Details != "")             {                 var tree_design = '';                 //sessionStorage.setItem("str_data", tree_design);                  var currDepth = 0;                 var totalData = $.map(Details, function (n, i) { return i; }).length;                 var lastNodeIndex = parseInt(totalData) - 0;                 //-----------------------------------------//                 $.each(Details, function (index, item)                 {                     if (Details[parseInt(index) + 0] === undefined || Details[parseInt(index) + 0] == null || Details[parseInt(index) + 0] == "")                      {                          //alert("undefined");                     }                     else                     {                         //console.log(index);                          //console.log(item.Name);                         //console.log(item.Depth);                         //alert(item.Depth);                         //console.log(item.Lft);                         //-----------------------------------//                         // Level down? (or the first)                         if (((parseInt(item.Depth) > parseInt(currDepth)) || parseInt(index) == 0) && parseInt(item.Depth) != 0) {                             tree_design += 'children: [';                         }                         //----------------------------------//                         // Level up?                         if (parseInt(item.Depth) < parseInt(currDepth)) {                             tree_design += '' + '}],'.repeat(parseInt(currDepth) - parseInt(item.Depth));                         }                         //----------------------------------//                         if (parseInt(item.Depth) != 0)                         {                             tree_design += '{ connectors: { style: { stroke: "#000000" } },';                         }                         //---------Print Node Text-------------//                         tree_design += 'text: { name: "' + item.Name + '" },HTMLclass: "blue",image: "images/no_member.png",';                         //---------------------------------------//                         //console.log(Details[parseInt(index) + 0].Depth);                         var nextEleDepth = Details[parseInt(index) + 0].Depth;                         //console.log(nextEleDepth);                          // Check if there's chidren                         if (parseInt(index) != lastNodeIndex && (parseInt(nextEleDepth) <= parseInt(item.Depth)))                         {                             tree_design += '},'; // If not, close the <li>                         }                         //---------------------------------------//                         // Adjust current depth                         currDepth = parseInt(item.Depth);                         //---------------------------------------//                         //console.log(parseInt(index)+"=="+lastNodeIndex);                         // Are we finished?                         if (parseInt(index) == lastNodeIndex) {                             //console.log("Are we finished");                             tree_design += '' + '}],'.repeat(currDepth);                         }                         //------------------------------------//                     }                 });                 //------------------Draw Tree---------------------------//                 //console.log(tree_design);                  var chart_config = {                     chart: {                         container: "#basic-example",                         nodeAlign: "BOTTOM",                         connectors: {                             type: "step"                         },                         node: {                             HTMLclass: "nodeExample0"                         }                     },                     nodeStructure: {                         t