cxzhq2002的杂记

cxzhq2002的杂记

Ajax二级动态菜单

//Multi_menu.htm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>MULTI-MENU</title>
<script type="text/javascript">
var currentPos="";
var http_request=false;
function send_request(method,url){
http_request=false;

// inital HttpRequest
if(window.XMLHttpRequest){//Mozilla
http_request = new XMLHttpRequest();
if(http_request.overrideMimeType){//set MIME
http_request.overrideMimeType("text/xml");
}//END SET MIME
}
else if(window.ActiveXObject){//IE Browser,Use Lasted version

var MSXML = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
for(var n = 0; n < MSXML.length; n ++)
{
try{
http_request = new ActiveXObject(MSXML[n]);
http_request.setRequestHeader("Content-Type","text/xml");
http_request.setRequestHeader('Content-Type', 'text/html; charset=gb2312'); //Last version need set, and it lik iFrame
if (method.toUpperCase( )=="POST" ){//post method
http_request.setRequestHeader('Connection', 'close');
http_request.setRequestHeader('Content-type','application/x-www-form-urlencoded');
}
break;
}
catch(e){http_request  = false;}
}//End IE
}// End inital HttpRequest

if(!http_request){//Error, Creat object fail
 window.alert("Cannot create an XMLHTTP instance")
 return false;
}
http_request.onreadystatechange = processRequest;
//get post or head, and asychFlag??
http_request.open(method, url,true);
http_request.send(null);
}// End send_request()

function processRequest(){
if(http_request.readyState == 4){
if(http_request.status == 200){
document.getElementById(currentPos).innerHTML= http_request.responseText;
}
else{
alert("Your Reqeust Page Error")}
}
}// End processRequest()

function showRole(obj){
if(document.getElementById(obj).parentNode.style.display=="none"){
document.getElementById(obj).parentNode.style.display="";
document.getElementById(obj).innerHTML ="loading...";
currentPos =obj;
//alert("ok");
send_request("post","mm.asp?playPos="+obj);
}
else{
document.getElementById(obj).parentNode.style.display="none";
}
}//End showRole

</script>

</head>
<body>
<table width="75%" border="1">
  <tr>
    <td><a href="javascript: void(0)" onClick="showRole('pos_1')" >经理室</a></td>
  </tr>
  <tr style="display:none">
    <td id="pos_1">&nbsp;</td>
  </tr>
  <tr>
    <td><a href="javascript: void(0)" onClick="showRole('pos_2')">开发部</a></td>
  </tr>
  <tr style="display:none">
    <td id="pos_2">&nbsp;</td>
  </tr>
</table>
</body>
</html>

//mm.asp

<% response.Charset="GB2312" '实现中文输出的关键%>
<%
playPos = request("playPos")
if playPos="pos_1" then 
response.Write("总经理<br>副经理") ''可以用数据库技术进行相关处理
elseif playPos="pos_2" then
response.Write("总工程师<br>软工程师")
end if
%>//

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cxzhq2002/article/details/820787
想对作者说点什么? 我来说一句

ajax动态树型菜单(jsp)

2009年09月08日 242KB 下载

没有更多推荐了,返回首页

不良信息举报

Ajax二级动态菜单

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭