xml|数据|异步
演示:http://asp2004.net/temp/treemenu/async.asp
源代码下载:http://asp2004.net/dvbbs/Dispbbs.asp?boardid=4&ID=89&replyID=375&skin=1
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>http://asp2004.net</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body >
<script language="javascript" src="function.js"></script>
<script language="javascript">
var isShow;
var isLoad;
isLoad = new ActiveXObject("Scripting.Dictionary");
//isShow = new ActiveXObject("Scripting.Dictionary");
function exe(id)
{
if (!isLoad.Exists(id))
{
isLoad.add(id,'');
loaddata(id);
}
/*
if(isShow.Exists(id))
{
isShow.Remove(id);
}
else
{
isShow.Add(id,'');
}
*/
if (id>0)
change1('a'+id,'b'+id);
}
function loaddata(id)
{
eval('c'+id).innerHTML = '正在加载。。。';
var xml = new ActiveXObject("Microsoft.XMLHTTP");
xml.open("GET","server.asp?id="+id,false);
xml.send();
var returnvalue = unescape(xml.ResponseText);
var m = returnvalue.split("#");
var str;
str="<table border='0' cellspacing='0' cellpadding='0'>";
var i=0,len=m.length-1;
for (;i<len;i++)
{
var n = m[i].split("*");
if ( n[0] > 0 )//有子节点
{
var listtype;
if ( i == len-1 )//最后一个
{
str += "<tr colspan='2' onClick=exe('" + n[1] + "');><td id='b" + n[1] + "' class='menu3'>" + n[3] + "</td></tr>";
listtype="list1";
}
else
{
str += "<tr colspan='2' onClick=exe('" + n[1] + "');><td id='b" + n[1] + "' class='menu1'>" + n[3] + "</td></tr>";
listtype="list";
}
str += "<tr id='a" + n[1] + "' style='display:none'><td id='c" + n[1] + "' class='" + listtype + "'></td>";
}
else//叶子节点
{
if ( i == len-1 )//最后一个
{
str += "<tr><td id='b" + n[1] + "' class='file1'><a href='" + n[4] + "' target='_blank'>" + n[3] + "</a></td></tr>";
}
else
{
str += "<tr><td id='b" + n[1] + "' class='file'><a href='" + n[4] + "' target='_blank'>" + n[3] + "</a></td></tr>";
}
}
}
str += "</table>";
eval('c'+id).innerHTML = str;
}
</script>
<a href="menu.asp">后台管理</a> 异步调用:<br>
<div id="c0"></div>
</body>
</html>