前端ajax请求编写:
$('#jstree-view').jstree({
'core': {
'data': {
cache: false,
'url': function (node) { //请求数据
var nodeId = node.id === "#" ? 'test/getUsersTreeRoot' : "test/getUsersTreeNode";
return nodeId;
},
dataType: 'json',
'data': function (node) { //返回前台
var node_mes = {'parent': node.id};
if (node.original) {
node_mes.dn = node.original.dn;
}
if (!node.parent) {
node_mes.parent = 'dc=maxcrcdc=com';
}
return node_mes;
},
"success":function (data) {
console.log(data);
},
"error": function (e) {
console.log('error');
}
},
"check_callback": true,
"multiple": false
},
后台php编写:
public function getUsersTreeRoot()
{
$parent = $this->input->get('parent');
$suffix = $this->session->userdata('suffix');
$filter = "(|(objectClass=domain)(objectClass=organizationalUnit))";
$ds = $this->_ldap->get_conn();
$sr=ldap_search($ds, $suffix, $filter);
$objects = ldap_get_entries($ds, $sr);
public function getUsersTreeNode()
{
$parent = $this->input->get('parent');
$dn = $this->input->get('dn');
$filter = "(objectClass=organizationalUnit)";
$suffix = $this->session->userdata('suffix');
$ds = $this->_ldap->get_conn();
$sr=ldap_search($ds, $dn, $filter);
$objects = ldap_get_entries($ds, $sr);
if (count($objects) == 2) {
$filter = '(isAdmin=0)';
$sr=ldap_search($ds, $dn, $filter);
$objects = ldap_get_entries($ds, $sr);
}
CI通过$this->input->get()获取传到后台的参数