jQuery EasyUI tree menu - to create an asynchronous tree menu
To create an asynchronous tree menu (Tree), and each tree node must have a 'id' attribute, this will be submitted back to the server to retrieve the child node data.
Create tree menu (Tree)
<Ul id = "tt" class = "easyui-tree" url = "tree2_getdata.php"> </ Ul>
Server-side code
$ Id = isset ($ _ POST [ 'id']) intval ($ _ POST [ 'id']): 0;? include 'conn.php'; $ Result = array (); $ Rs = mysql_query ( "select * from nodes where parentId = $ id"); while ($ row = mysql_fetch_array ($ rs)) { $ Node = array (); $ Node [ 'id'] = $ row [ 'id']; $ Node [ 'text'] = $ row [ 'name']; ? $ Node [ 'state'] = has_child ($ row [ 'id']) 'closed': 'open'; array_push ($ result, $ node); } echo json_encode ($ result); function has_child ($ id) { $ Rs = mysql_query ( "select count (*) from nodes where parentId = $ id"); $ Row = mysql_fetch_array ($ rs); return $ row [0]> 0 true:? false; }