<html> <head> <link rel="stylesheet" href="dist/themes/default/style.min.css" /> <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> <script src="dist/jstree.min.js"></script> <script> $(function() { $.ajax({ async : true, type : "GET", url : "server.php", dataType : "json",
success : function(json) { createJSTrees(json); },
error : function(xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); } }); });
function createJSTrees(jsonData) { $("#jstree").jstree({ "json_data" : { "data" : jsonData }, "plugins" : [ "themes", "json_data", "ui" ] }); } </script> </head> <body> <div id="jstree"> </div> </body></html><?php //up here is have the db connect stuff but i took it away for save keeping!! just pretend its here $sql = ""; $q = "SELECT * FROM mytree WHERE parent_id = '0'"; $q = mysql_query($q); $rows = array(); while($r = mysql_fetch_assoc($q)) { $rows[] = $r; } echo json_encode($rows); ?>
createJSTrees(json))? Log it out and paste it here.