不多说直接上代码
js
var setting = { data: { simpleData: { idKey: "id", pIdKey: "pid", enable: true } }, callback: { onClick: onClick } }; var zNodes; function zTreeInit() { $.ajax({ url: '....', type: 'POST', dataType: "json", data: {id: ""}, async: false, success: function (data) { var d = $.parseJSON(data); zNodes = d; } }); $.fn.zTree.init($("#orgTree"), setting, zNodes); } function onClick(event, treeId, treeNode, clickFlag) { //treeNode.id; // treeNode.name; }