I am using easy ui tree plugin in my project , currently i am loading the tree using php
<div id="dg" class="easyui-panel" style="padding:5px;" >
<?php
$menu = array('items' => array(),'parents' => array());
foreach ($results as $items) {
$menu['items'][$items['position']] = $items;
$menu['parents'][$items['immediate_parent']][] = $items['position'];
}
function buildMenu($parent, $menu)
{
$html = "";
if (isset($menu['parents'][$parent])) {
$html .= "
<ul class='easyui-tree' data-options='lines:true'>
";
foreach ($menu['parents'][$parent] as $itemId) {
$pos_val = "\"" . $menu['items'][$itemId]['position'] . "\"";
$checkval = $menu['items'][$itemId]['position'];
if (!isset($menu['parents'][$itemId])) {
$html .= "<li>
" . ucfirst($menu['items'][$itemId]['Item']) . "" . "<a id='addnode$checkval'style='padding-left:5px;' onclick='addNode(" . $pos_val . ",\"" . $menu['items'][$itemId]['Item'] . "\");'
href='javascript:void(0);' title='Add'><i class='fa fa-plus-square' style='color:#2DCB70'></i></a><a onclick='editNode(\"".$menu['items'][$itemId]['id']."\");' href='javascript:void(0);' title='Edit'>
<i class='fa fa-pencil-square-o'></i></a><a onclick='deleteNode(\"".$menu['items'][$itemId]['id']."\");' href='javascript:void(0);' title='Delete'>
<i class='fa fa-trash-o'></i></a>";
}
if (isset($menu['parents'][$itemId])) {
$html .= "
<li><span>" . ucfirst($menu['items'][$itemId]['Item']) . "" . "<a style='padding-left:5px;' onclick='addNode(" . $pos_val . ",\"" . $menu['items'][$itemId]['Item'] . "\");'
href='javascript:void(0);'><i class='fa fa-plus-square' style='color:#2DCB70'></i> </a></span>";
$html .= buildMenu($itemId, $menu);
$html .= "</li>
";
}
}
$html .= "</ul>
";
}
return $html;
}
echo buildMenu(0, $menu);
?>
</div>
this is the code that i am using. Now i want to load this tree in an ajax page load i dont know how to embedd this code in ajax .
This is the db structure that i am using