700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > JQuery ztree 异步加载实例讲解【jquery】

JQuery ztree 异步加载实例讲解【jquery】

时间:2022-09-03 13:34:41

相关推荐

JQuery ztree 异步加载实例讲解【jquery】

web前端|js教程

jquery,异步加载

web前端-js教程

本来要做一个文件目录浏览界面,需要遍历所有的文件和目录,很显然一次性读取时很费时费力的一件事情。

vc6 源码编码,vscode编译网页,ubuntu ug,tomcat 内存监测,sqlite3库路径,微信公众平台插件开源免费框架无法继续安装,php要不要学前端框架,爬虫视频教程哪家好,php 正则表达式替换,保山seo优化推广,水处理网站源码,日志网页源码,帝国cms 内容页 模板下载lzw

因此就需要做异步加载….

心跳拦截源码,ubuntu18 tty,tomcat的登陆账号,学爬虫工作,php实现分期付款,对比seolzw

准备工作:

源码可靠网站,ubuntu界面大小变化,怎么测试tomcat运行了,py爬虫开发,php网站打开速度优化,seo参透lzw

1下载 JQuery ZTree

复制其中的JS和CSS即可,其实没必要引那么多,用什么引什么就可以。

2 需要fastJSON,用来转换JSON对象

我下载JAR包后,引入到Eclipse中总是报找不到class错误。

解决办法:把jar包放在WEB-INF/lib下即可。

代码实例:

index.jsp

Insert title herevar setting = { data: { simpleData: { enable: true } } , async: {enable: true,url:"/TestZTree/test",autoParam:["id", "name", "level"],otherParam:{"otherParam":"zTreeAsyncTest"},dataFilter: filter } };function filter(treeId, parentNode, childNodes) {if (!childNodes) return null;for (var i=0, l=childNodes.length; i<l; i++) { childNodes[i].name = childNodes[i].name.replace(/\.n/g, .);}return childNodes; } var zNodes =[ { id:1, pId:0, name:"parentNode 1", open:true}, { id:11, pId:1, name:"parentNode 11",isParent:true}, { id:111, pId:11, name:"leafNode 111"}, { id:112, pId:11, name:"leafNode 112"}, { id:12, pId:1, name:"parentNode 12",isParent:true}, { id:121, pId:12, name:"leafNode 121"}, { id:13, pId:1, name:"parentNode 13", isParent:true}, { id:2, pId:0, name:"parentNode 2", isParent:true}];$(document).ready(function(){ $.fn.zTree.init($("#treeDemo"), setting, zNodes);});

testServlet.java

package com.test;import java.io.IOException;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.alibaba.fastjson.JSON;import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject;public class testServlet extends HttpServlet{ @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doPost(request, response); } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String id = request.getParameter("id");String name = request.getParameter("name");String level = request.getParameter("level");String otherParam = request.getParameter("otherParam");System.out.println(id + "|" + name + "|" + level + "|" + otherParam);List<HashMap> list = new ArrayList<HashMap>();for(int i = 0; i < 5; i++){ HashMap hm = new HashMap(); //最外层,父节点 hm.put("id",id+i);//id属性 ,数据传递 hm.put("name", id+i); //name属性,显示节点名称 hm.put("pId", id); list.add(hm);}response.getWriter().write(JSON.toJSONString(list)); } }

web.xml

testServlet com.test.testServlet testServlet /test index.jsp

效果图:

以上就是关于jquery异步加载,希望对大家学习jquery程序设计有所帮助。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。