后台获取json格式数据。
直接上代码。 最后有一张官方ajax获取tree的说明。
var ajaxTreeSample = function() {
$("#tree_4").jstree({
"core" : {
"themes" : {
"responsive": false
},@H_502_22@// so that create works
"check_callback" : true,'data' : function (obj,callback) {
var jsonstr="[]";
var jsonarray = eval('('+jsonstr+')');
$.ajax({
type: "POST",url:"/bms/wechat/wemenu/show.do",dataType:"json",async: false,success:function(result) {
var arrays= result.data;
for(var i=0 ; i<arrays.length; i++){
var arr = {
"id":arrays[i].menuId,"parent":arrays[i].parentId=="root"?"#":arrays[i].parentId,"text":arrays[i].menuName
}
jsonarray.push(arr);
}
}
});
callback.call(this,jsonarray);
}
},"types" : {
"default" : {
"icon" : "fa fa-folder icon-state-warning icon-lg"
},"file" : {
"icon" : "fa fa-file icon-state-warning icon-lg"
}
},"state" : { "key" : "demo3" },"plugins" : [ "dnd","state","types" ]
});
}
原文链接:https://www.f2er.com/ajax/161510.html