How to create tree view structure by fetching data from sql?
HI All, I am trying to create the tree view by fetching data from sql db.please need help to solve this. the code i have tried is *************************** I am trying to build a tree structure by fetching data from mysql database. <!DOCTYPE html> <html> <head> <title>Media chain</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.css" /> <script type="text/javascript" charset="utf8" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js"></script> <script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js"></script> </head> <body> <div class="container"> <div class="panel panel-default"> <div class="panel-heading"> <h1>Media chain</h1> </div> <div class="panel-body"> <div class="col-md-8" id="treeview_json"> </div> </div> </div> </div> <script type="text/javascript"> $(document).ready(function(){ // var parentKey='0'; var subdata=[];var data; $.ajax({ type: "GET", url: "/mediaChain", dataType: "json", success: function(response) { $.each(response, function(i, item) { var child=item["Child"]; subdata["Licensor"]=item["Licensor"]; subdata["Parent"]=item["Parent"]; subdata["Child"]=item["Child"]; subdata.push(item); }); var output=[]; $.each( subdata, function( key, value ) {