zTree异步加载简单实例讲解_jquery_脚本之家

以上就是jquery
zTree异步加载实例分享给大家,希望对大家学习异步加载技术有所帮助。

本文实例讲解了jquery zTree异步加载,分享给大家供大家参考,具体内容如下

 getDataServlet; testTree.TestTree; getDataServlet; /getData; ZTREE DEMO - Simple Data &lt;!-- var setting = { data: { simpleData: { enable: true } } ,async: { enable: true, url:"/testJQuery/getData", autoParam:["id", "name"], otherParam:{"otherParam":"zTreeAsyncTest"}, dataFilter: filter } }; function filter(treeId, parentNode, childNodes) { if return null; for (var i=0, l=childNodes.length; i&lt;l; i++) { childNodes[i].name = childNodes[i].name.replace; } return childNodes; } var zNodes =[ { id:1, pId:0, name:"parentNode 1", open:true}, { id:11, pId:1, name:"parentNode 11"}, { id:111, pId:11, name:"leafNode 111"}, { id:112, pId:11, name:"leafNode 112"}, { id:113, pId:11, name:"leafNode 113"}, { id:114, pId:11, name:"leafNode 114"}, { id:12, pId:1, name:"parentNode 12"}, { id:121, pId:12, name:"leafNode 121"}, { id:122, pId:12, name:"leafNode 122"}, { id:123, pId:12, name:"leafNode 123"}, { id:13, pId:1, name:"parentNode 13", isParent:true}, { id:2, pId:0, name:"parentNode 2", isParent:true} ]; $.ready{ $.fn.zTree.init, setting, zNodes); }); //--&gt; 最简单的树 -- 简单 JSON 数据 [ 文件路径: core/simpleData.html ] public class TestTree extends HttpServlet { @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // System.out.println("--------doGet--------"); this.doPost; } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // System.out.println("--------doPost--------"); String id = request.getParameter; String name = request.getParameter; String level = request.getParameter; String otherParam = request.getParameter; System.out.println(id + "|" + name + "|" + level + "|" + otherParam); JSONObject json = new JSONObject(); List> list = new ArrayList>(); for(int i = 0; i < 5; i++){ HashMap hm = new HashMap(); //最外层,父节点 hm.put;//id属性 ,数据传递 hm.put; //name属性,显示节点名称 hm.put; list.add; } JSONArray arr = new JSONArray; json.put; json.put; System.out.println("--------json------" + json.toString; response.getWriter().write; // response.getWriter().write; // response.getWriter().write("[{pId:'2',name:'20',id:'20'}]"); } } 

188金宝搏,web.xml中Servlet配置如下:

相关文章

Comment ()
评论是一种美德,说点什么吧,否则我会恨你的。。。