ajax

/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.gcg.struts.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.MappingDispatchAction;

import com.gcg.Ajaxtree;
import com.gcg.service.Ajax;
import com.gcg.struts.form.TreeForm;
/** 
 * MyEclipse Struts
 * Creation date: 04-01-2010
 * 
 * XDoclet definition:
 * @struts.action path="/tree" name="treeForm" input="/tree/treeadd.jsp" scope="request" validate="true"
 * @struts.action-forward name="success" path="/index.jsp"
 */
public class TreeAction extends MappingDispatchAction {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	private Ajax ajax;
	public ActionForward add(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		TreeForm treeForm = (TreeForm) form;
		return null;
	}
	
	public ActionForward ajax(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		Long parentid = Long.parseLong(request.getParameter("id"));
		Long level = Long.parseLong(request.getParameter("level").trim());
		
		if(level==2L){
			List<Map<Object,Object>> ls = ajax.getLevel2(parentid);
			response.setContentType("text/xml");
			response.setHeader("Cache-Control", "no-cache");
			PrintWriter out=response.getWriter();
			out.print(parseTreeInfoToXM(ls ,parentid ,level).toString());
			out.flush();
			out.close();
		}else if(level == 3L){
			List<Map<Object,Object>> ls = ajax.getLevel3(parentid);
			response.setContentType("text/xml");
			response.setHeader("Cache-Control", "no-cache");
			PrintWriter out=response.getWriter();
			out.print(parseTreeInfoToXM(ls ,parentid ,level).toString());
			out.flush();
			out.close();
		}else{
			System.out.println(level);
			throw new IllegalArgumentException("参数level非法");
		}
		return null;
	}
	public ActionForward init(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		List<Map<Object,Object>> ls = ajax.getLevel1();
		response.setContentType("text/xml");
		response.setHeader("Cache-Control", "no-cache");
		
		PrintWriter out=response.getWriter();
		StringBuffer sb = parseTreeInfoToXM(ls ,0L ,0L);
		System.out.println(sb);
		out.print(sb);
		out.flush();
		out.close();
		return null;
	}
	public StringBuffer parseTreeInfoToXM(List ls ,Long parentid , Long level){
		StringBuffer sb = new StringBuffer();
		sb.append("<?xml version='1.0' encoding='UTF-8'?>");
		sb.append("<trees>");
		if(parentid != 0){
			sb.append("<parentid>" + parentid + "</parentid>");
		}
		if(level != 0 ){
			sb.append("<level>" + level + "</level>");
		}
		for(int i=0 ;i<ls.size(); ++i){
			sb.append("<tree>");
			Map<Object,Object> map = (Map)ls.get(i);
			Boolean isHaveChild = (Boolean)map.get("isHaveChild");
			if(isHaveChild == true){
				sb.append("<isHaveChild>true</isHaveChild>");
			}else{
				sb.append("<isHaveChild>false</isHaveChild>");
			}
			Ajaxtree ajaxtree = (Ajaxtree)map.get("ajaxtree");
			Long id = ajaxtree.getId();
			sb.append("<id>" + id + "</id>");
			String name = ajaxtree.getName();
			sb.append("<name>" + name + "</name>");
			sb.append("</tree>");
		}
		sb.append("</trees>");
		return sb;
	}
	public Ajax getAjax() {
		return ajax;
	}

	public void setAjax(Ajax ajax) {
		this.ajax = ajax;
	}
}
 
package com.gcg.serviceimpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.gcg.Ajaxtree;
import com.gcg.AjaxtreeDAO;
import com.gcg.service.Ajax;

public class AjaxTreeService implements Ajax {

	private AjaxtreeDAO ajxtreeDAO;
//	public void addTreeNode(Ajaxtree ajaxtree) throws RuntimeException {
//		// TODO Auto-generated method stub
//		try {
//			ajxtreeDAO.save(ajaxtree);
//		} catch (RuntimeException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//			throw e;
//		}
//
//	}
//
//	public void deleteTreeNod(Long id) throws RuntimeException {
//		// TODO Auto-generated method stub
//		try {
//			ajxtreeDAO.deleteByID(id);
//		} catch (RuntimeException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//			throw e;
//		}
//
//	}
//	
//	public List<Map<Object, Object>> getAjaxResult(Long id) throws RuntimeException {
//		// TODO Auto-generated method stub
//		List<Map<Object, Object>> childAllInfo = new ArrayList();
//		try {
//		
//			List<Object> childInfo = ajxtreeDAO.getChildrens(id);
//			
//			for(int i=0 ;i<childInfo.size() ;++i ){
//				Map<Object,Object> childSumInfo = new HashMap();
//				Ajaxtree ajaxtree = (Ajaxtree)childInfo.get(i);
//				Long childId = ajaxtree.getId();
//				childSumInfo.put(i, ajaxtree);
//				
//				boolean isHaveChild = ajxtreeDAO.isHaveChild(childId);
//				childSumInfo.put("isHaveChild", isHaveChild);
//				childAllInfo.add(childSumInfo);
//			}
//		} catch (RuntimeException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//			throw e;
//		}
//		return childAllInfo;
//	}
//
//	public List<Object> getPidNullInfo() throws RuntimeException {
//		// TODO Auto-generated method stub
//		List<Object> ls = null;
//		try {
//			ls = ajxtreeDAO.getPidNullIInfo();
//		} catch (RuntimeException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//			throw e;
//		}
//		return ls;
//	}
//	public List<Map<Object, Object>> getAjaxResultPIDisNull()
//			throws RuntimeException {
//		List<Map<Object, Object>> childAllInfo = null;
//		try {
//			childAllInfo = new ArrayList();
//			
//			List<Object> childInfo = ajxtreeDAO.getPidNullIInfo();
//			for(int i=0 ;i<childInfo.size() ;++i ){
//				Map<Object,Object> childSumInfo = new HashMap();
//				Ajaxtree ajaxtree = (Ajaxtree)childInfo.get(i);
//				Long childId = ajaxtree.getId();
//				childSumInfo.put("ajaxtree", ajaxtree);
//				
//				boolean isHaveChild = ajxtreeDAO.isHaveChild(childId);
//				childSumInfo.put("isHaveChild", isHaveChild);
//				childAllInfo.add(childSumInfo);
//			}
//		} catch (RuntimeException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//			throw e;
//		}
//		return childAllInfo;
//	}
	

	public List getLevel1() throws RuntimeException {
		List<Map<Object, Object>> childAllInfo = null;
		try {
			childAllInfo = new ArrayList();
			
			List<Ajaxtree> childInfo = ajxtreeDAO.getLeve1();
			for(int i=0 ;i<childInfo.size() ;++i ){
				Map<Object,Object> childSumInfo = new HashMap();
				Ajaxtree ajaxtree = (Ajaxtree)childInfo.get(i);
				Long childId = ajaxtree.getId();
				childSumInfo.put("ajaxtree", ajaxtree);
				
				boolean isHaveChild = ajxtreeDAO.isHaveChild(childId);
				childSumInfo.put("isHaveChild", isHaveChild);
				childAllInfo.add(childSumInfo);
			}
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return childAllInfo;
	}

	public List getLevel2(Long id) throws RuntimeException {
		List<Map<Object, Object>> childAllInfo = null;
		try {
			childAllInfo = new ArrayList();
			
			List<Ajaxtree> childInfo = ajxtreeDAO.getLeve2(id);
			for(int i=0 ;i<childInfo.size() ;++i ){
				Map<Object,Object> childSumInfo = new HashMap();
				Ajaxtree ajaxtree = (Ajaxtree)childInfo.get(i);
				Long childId = ajaxtree.getId();
				childSumInfo.put("ajaxtree", ajaxtree);
				
				boolean isHaveChild = ajxtreeDAO.isHaveChild(childId);
				childSumInfo.put("isHaveChild", isHaveChild);
				childAllInfo.add(childSumInfo);
			}
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return childAllInfo;
	}

	public List getLevel3(Long id) throws RuntimeException {
		List<Map<Object, Object>> childAllInfo = null;
		try {
			childAllInfo = new ArrayList();
			
			List<Ajaxtree> childInfo = ajxtreeDAO.getLeve3(id);
			for(int i=0 ;i<childInfo.size() ;++i ){
				Map<Object,Object> childSumInfo = new HashMap();
				Ajaxtree ajaxtree = (Ajaxtree)childInfo.get(i);
				Long childId = ajaxtree.getId();
				childSumInfo.put("ajaxtree", ajaxtree);
				
				boolean isHaveChild = ajxtreeDAO.isHaveChild(childId);
				childSumInfo.put("isHaveChild", isHaveChild);
				childAllInfo.add(childSumInfo);
			}
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return childAllInfo;
	}
	public AjaxtreeDAO getAjxtreeDAO() {
		return ajxtreeDAO;
	}

	public void setAjxtreeDAO(AjaxtreeDAO ajxtreeDAO) {
		this.ajxtreeDAO = ajxtreeDAO;
	}

	
}
 
package com.gcg;

import java.util.HashSet;
import java.util.Set;

/**
 * Ajaxtree entity.
 * 
 * @author MyEclipse Persistence Tools
 */

public class Ajaxtree implements java.io.Serializable {

	// Fields

	private Long id;
	private Ajaxtree ajaxtree;
	private String name;
	private Set ajaxtrees = new HashSet(0);

	// Constructors

	/** default constructor */
	public Ajaxtree() {
	}

	/** minimal constructor */
	public Ajaxtree(String name) {
		this.name = name;
	}

	/** full constructor */
	public Ajaxtree(Ajaxtree ajaxtree, String name, Set ajaxtrees) {
		this.ajaxtree = ajaxtree;
		this.name = name;
		this.ajaxtrees = ajaxtrees;
	}

	// Property accessors

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Ajaxtree getAjaxtree() {
		return this.ajaxtree;
	}

	public void setAjaxtree(Ajaxtree ajaxtree) {
		this.ajaxtree = ajaxtree;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set getAjaxtrees() {
		return this.ajaxtrees;
	}

	public void setAjaxtrees(Set ajaxtrees) {
		this.ajaxtrees = ajaxtrees;
	}
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.gcg.Ajaxtree" table="AJAXTREE" schema="SYSTEM">
        <id name="id" type="java.lang.Long">
            <column name="ID" precision="10" scale="0" />
            <generator class="sequence" />
        </id>
        <many-to-one name="ajaxtree" class="com.gcg.Ajaxtree" fetch="join">
            <column name="PID" precision="10" scale="0" />
        </many-to-one>
        <property name="name" type="java.lang.String">
            <column name="NAME" length="50" not-null="true" />
        </property>
        <set name="ajaxtrees" inverse="true" lazy="true">
            <key>
                <column name="PID" precision="10" scale="0" />
            </key>
            <one-to-many class="com.gcg.Ajaxtree" />
        </set>
    </class>
</hibernate-mapping>
package com.gcg;

import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * A data access object (DAO) providing persistence and search support for
 * Ajaxtree entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.gcg.Ajaxtree
 * @author MyEclipse Persistence Tools
 */

public class AjaxtreeDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(AjaxtreeDAO.class);
	// property constants
	public static final String NAME = "name";

	protected void initDao() {
		// do nothing
	}

	public void save(Ajaxtree transientInstance) {
		log.debug("saving Ajaxtree instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	public Boolean isHaveChild(Long id){
		List<Integer> ls = null;
		try {
			String query = "select count(*) from Ajaxtree a inner join a.ajaxtrees c where c.ajaxtree.id = ? ";
			ls = getHibernateTemplate().find(query ,id );
		} catch (DataAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return ls.size() > 0;
	}
	public List<Object> getChildrens(Long id){
		List<Object> ls = null;
		try {
			String query = "select a.ajaxtrees from Ajaxtree a where a.id = ? ";
			ls = getHibernateTemplate().find(query , id);
		} catch (DataAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return ls;
	}
	public List<Ajaxtree> getLeve1(){
		List<Ajaxtree> ls = null;
		try {
			String query = " from Ajaxtree a where a.ajaxtree =null ";
			ls = getHibernateTemplate().find(query);
		} catch (DataAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return ls;
	}
	public List<Ajaxtree> getLeve2(Long id){
		List<Ajaxtree> ls = null;
		try {
			String query = "select a.ajaxtrees from Ajaxtree a where a.ajaxtree =null and a.id=?";
			ls = getHibernateTemplate().find(query, id);
		} catch (DataAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return ls;
	}
	public List<Ajaxtree> getLeve3(Long id){
		List<Ajaxtree> ls = null;
		try {
			String query = "select a.ajaxtrees from Ajaxtree a where a.ajaxtree !=null and a.id=?";
			ls = getHibernateTemplate().find(query, id);
		} catch (DataAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return ls;
	}
	
	public List<Object> getPidNullIInfo(){
		List<Object> ls = null;
		try {
			String query = "select a.ajaxtrees from Ajaxtree a where a.ajaxtree=null ";
			ls = getHibernateTemplate().find(query);
		} catch (DataAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return ls;
	}
	
	public void delete(Ajaxtree persistentInstance) {
		log.debug("deleting Ajaxtree instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	public void deleteByID(Long ID) {
		log.debug("deleting Ajaxtree instance");
		try {
			String query = "delete from Ajaxtree a where a.id = ? ";
			getHibernateTemplate().bulkUpdate(query, ID);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	public Ajaxtree findById(java.lang.Long id) {
		log.debug("getting Ajaxtree instance with id: " + id);
		try {
			Ajaxtree instance = (Ajaxtree) getHibernateTemplate().get(
					"com.gcg.Ajaxtree", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Ajaxtree instance) {
		log.debug("finding Ajaxtree instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Ajaxtree instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Ajaxtree as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByName(Object name) {
		return findByProperty(NAME, name);
	}

	public List findAll() {
		log.debug("finding all Ajaxtree instances");
		try {
			String queryString = "from Ajaxtree";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public Ajaxtree merge(Ajaxtree detachedInstance) {
		log.debug("merging Ajaxtree instance");
		try {
			Ajaxtree result = (Ajaxtree) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(Ajaxtree instance) {
		log.debug("attaching dirty Ajaxtree instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Ajaxtree instance) {
		log.debug("attaching clean Ajaxtree instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static AjaxtreeDAO getFromApplicationContext(ApplicationContext ctx) {
		return (AjaxtreeDAO) ctx.getBean("AjaxtreeDAO");
	}
}  
}
 
<%@ page language="java"  pageEncoding="UTF-8"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <script type="text/javascript" language="JavaScript">
  	var xmlrequest;
    function createXMLHttpRequest()
	{
		if(window.XMLHttpRequest)
		{ //Mozilla 浏览器
			xmlrequest = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			// IE浏览器
			try
			{
				xmlrequest = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlrequest = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
				}
			}
		}
	}
  function initNav() {
  	createXMLHttpRequest(); 
  	var uri = "${pageContext.request.contextPath}/ajaxInitTree.do";
  	xmlrequest.open("POST", uri, true); 
  	xmlrequest.setRequestHeader("Content-Type"
			, "application/x-www-form-urlencoded");
	xmlrequest.onreadystatechange = processResponse;
	xmlrequest.send(null); 		
  }
  function processResponse(){
  	if (xmlrequest.readyState == 4)
		{
			// 判断对象状态
			if (xmlrequest.status == 200)
			{
				// 信息已经成功返回,开始处理信息

				var doc = xmlrequest.responseXML;
				var trees = doc.getElementsByTagName("tree");
			//	alert(trees.length);
				for(var i=0;i<trees.length;++i){
					var ishavechild = trees.item(i).getElementsByTagName('isHaveChild').item(0).firstChild.nodeValue;
					var id = trees.item(i).getElementsByTagName('id').item(0).firstChild.nodeValue;
					var name = trees.item(i).getElementsByTagName('name').item(0).firstChild.nodeValue;
					var parentid = 0;
					var level = 1;
					createTree(parentid ,ishavechild , id , name ,level);
				}
				
            }
			else
			{
				//页面不正常
                window.alert("您所请求的页面有异常。");
            }
        }
    }
  function createTree(parentid ,ishavechild , id ,name ,level){
  		
		if(parentid == 0){	
		   var level = level + 1;
  		   var vdiv = document.createElement("div");
  		   vdiv.setAttribute("id",id);
  		   if(ishavechild == 'true'){
  			  vdiv.innerHTML ="<div id="+'node'+id+''+level+''+">"+
  							  "<a href="+'javascript:expandtree('+id+','+level+');>' +
  								 "<img id="+'img'+id +' '+level+ " src='img/plus.gif'>" +
  							  "</a>"+
  							  "<img id="+'folder'+id+' '+level+" src='img/folder.gif'>"+
  							  "<a href="+'javascript:expandtree('+id+','+level+');>'+name+"</a>"+
  							  "</div>";
  		   }else{
  			  vdiv.innerHTML ="<div class='node'>"+
  							  "<img  src='img/folder.gif' id='folder'"+id+">"+
  							  "<a href='#'>"+name+"</a>"+
  							  "</div>";
  		   }
  		   document.getElementById("nav").appendChild(vdiv);
  		}else{
  			
  			var parentDiv = document.getElementById('node'+parentid+''+level);
  			var level =parseInt(level) + 1;
  			alert(parentDiv.innerHTML);
  			var vdiv = document.createElement("div");
  		   	vdiv.setAttribute("id",id);
  		   	if(ishavechild == 'true'){
  			  	vdiv.innerHTML ="<div id="+'node'+id+''+level+''+">"+
  							  	"<a href="+'javascript:expandtree('+id+','+level+');>' +
  								 	"<img id="+'img'+id +' '+level+ " src='img/plus.gif'>" +
  							  	"</a>"+
  							  	"<img id="+'folder'+id+' '+level+" src='img/folder.gif'>"+
  							  	"<a href="+'javascript:expandtree('+id+','+level+');>'+name+"</a>"+
  							  	"</div>";
  		   }else{
  			  	vdiv.innerHTML ="<div class='node'>"+
  							  	"<img  src='img/folder.gif' id='folder'"+id+">"+
  							  	"<a href='#'>"+name+"</a>"+
  							  	"</div>";
  		   }
  		   parentDiv.appendChild(vdiv);
  		}
  		
  }
  function expandtree(parentid ,level){
  		createXMLHttpRequest(); 
  		var uri = "${pageContext.request.contextPath}/ajaxAppendTree.do?id="+parentid+"&level="+level;
  		xmlrequest.open("POST", uri, true); 
  		xmlrequest.setRequestHeader("Content-Type"
			, "application/x-www-form-urlencoded");
		xmlrequest.onreadystatechange = processExpandtree;
		xmlrequest.send(null); 
  }
  function processExpandtree(){
  if (xmlrequest.readyState == 4)
		{
			// 判断对象状态
			if (xmlrequest.status == 200)
			{
				// 信息已经成功返回,开始处理信息

				var doc = xmlrequest.responseXML;
				var trees = doc.getElementsByTagName("tree");
				var parentid = doc.getElementsByTagName("parentid").item(0).firstChild.nodeValue;
				var level = doc.getElementsByTagName("level").item(0).firstChild.nodeValue
			//	alert(trees.length);
			
				for(var i=0;i<trees.length;++i){
					var ishavechild = trees.item(i).getElementsByTagName('isHaveChild').item(0).firstChild.nodeValue;
					var id = trees.item(i).getElementsByTagName('id').item(0).firstChild.nodeValue;
					var name = trees.item(i).getElementsByTagName('name').item(0).firstChild.nodeValue;
					
					createTree(parentid ,ishavechild , id ,name ,level);
				}
				
            }
			else
			{
				//页面不正常
                window.alert("您所请求的页面有异常。");
            }
        }
    }
  </script>
    <title>AJAX 树</title>
  </head>
  
  <body οnlοad="initNav()">
	<div id="nav">
	</div>
  </body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值