JQuery ztree asynchronous loading example, jqueryztree

Source: Internet
Author: User

JQuery ztree asynchronous loading example, jqueryztree

To do a file directory browsing interface, you need to traverse all the files and directories. It is obviously time-consuming and labor-consuming to read files and directories at a time.

Therefore, we need to doAsynchronous loading....

Preparations:

1 download JQuery ZTree

Copy the JS and CSS in it. In fact, there is no need to introduce so much. You can use anything to introduce it.

2. fastJSON is required to convert JSON objects.

After downloading the JAR package, I always report that the class error cannot be found in Eclipse.

Solution: Put the jar package under the WEB-INF/lib.

Code example:

Index. jsp

<%@ page language="java" contentType="text/html; charset=utf-8"  pageEncoding="utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

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 <String, object> list = new ArrayList <HashMap <String, Object> (); for (int I = 0; I <5; I ++) {HashMap <String, object> hm = new HashMap <String, Object> (); // outermost layer, parent node hm. put ("id", id + I); // id attribute, data transmission hm. put ("name", id + I); // name attribute, displaying the node name hm. put ("pId", id); list. add (hm);} response. getWriter (). write (JSON. toJSONString (list ));}}

Web. xml

<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5"   xmlns="http://java.sun.com/xml/ns/javaee"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name></display-name> <servlet>  <servlet-name>testServlet</servlet-name>  <servlet-class>com.test.testServlet</servlet-class> </servlet> <servlet-mapping>  <servlet-name>testServlet</servlet-name>  <url-pattern>/test</url-pattern> </servlet-mapping>    <welcome-file-list>  <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>

:

The above is about jquery asynchronous loading, hoping to help you learn jquery programming.

Articles you may be interested in:
  • Jquery zTree asynchronous loading simple instance sharing
  • Struts2 + jquery + json Implement Asynchronous Data Loading (self-writing)
  • Implementation example of JQuery asynchronous loading of the infinite drop-down box cascade Function
  • Jquery ztree uses json data in the drop-down tree.
  • Summary of common functions and features of the infinite tree Jquery plug-in zTree
  • Getting started with Jquery tree plug-in zTree
  • Code for menu effects of an infinite tree structure implemented by json + jQuery
  • Learn how to create a tree menu by using the jQuery plug-in EasyUI
  • Jquery ztree for tree search
  • JQuery uses the zTree plug-in to implement tree menu and asynchronous loading

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.