Ajax按需讀取數(shù)據(jù)生成下級(jí)菜單
<script language="javascript">
var http_request=false;
function send_request(url){//初始化,指定處理函數(shù),發(fā)送請(qǐng)求的函數(shù)
http_request=false;
//開(kāi)始初始化XMLHttpRequest對(duì)象
if(window.XMLHttpRequest){//Mozilla瀏覽器
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){//設(shè)置MIME類型
http_request.overrideMimeType("text/html");
}
}
else if(window.ActiveXObject){//IE瀏覽器
try{
http_request=new ActiveXObject("Xsxml2.XMLHTTP");
http_request.setRequestHeader("Content-Type","text/xml");
http_request.setRequestHeader("Content-Type","gb2312");
}
catch(e){
try{
http_request=new ActiveXObject("Microsoft.XMLHTTP");
http_request.setRequestHeader("Content-Type","text/xml");
http_request.setRequestHeader("Content-Type","gb2312");
}
catch(e){
}
}
}
if(!http_request){//異常,創(chuàng)建對(duì)象實(shí)例失敗
window.alert("不能創(chuàng)建XMLHttpRequest對(duì)象實(shí)例");
return false;
}
http_request.onreadystatechange=processRequest;
//確定發(fā)送請(qǐng)求的方式和URL以及是否同步執(zhí)行下段代碼
http_request.open("GET",url,true);
http_request.send(null);
}
//處理返回信息的函數(shù)
function processRequest(){
if(http_request.readyState==4){//判斷對(duì)象狀態(tài)
if(http_request.status==200){//信息已經(jīng)成功返回,開(kāi)始處理信息
document.getElementById(currentPos).innerHTML=http_request.responseText;
}
else{//頁(yè)面不正常
alert("您所請(qǐng)求的頁(yè)面有異常");
}
}
}
function showRoles(obj){
document.getElementById(obj).parentNode.style.display="";
document.getElementById(obj).innerHTML="正在讀取數(shù)據(jù)..."
currentPos=obj;
send_request("jilian_data.asp?playPos="+obj);
}
</script>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20">
<a href="javascript:void(0)" onclick="showRoles('pos_1')">經(jīng)理室
</a>
</td>
</tr>
<tr style="display:none">
<td height="20" id="pos_1"> </td>
</tr>
<tr>
<td height="20">
<a href="javascript:void(0)" onclick="showRoles('pos_2')">開(kāi)發(fā)部</a>
</td>
</tr>
<tr style="display:none">
<td id="pos_2" height="20"> </td>
</tr>
</td>
</table>
jilian_data.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
playPos=request("playPos")
if playPos="pos_1" then
Response.Write(" jingli<br> 副總經(jīng)理")
end if
if playPos="pos_2" then
Response.Write(" 總工程師<br> 軟件工程師")
end if
%>
相關(guān)文章
使用Ajax模仿百度搜索框的自動(dòng)提示功能實(shí)例
今天小編就為大家分享一篇使用Ajax模仿百度搜索框的自動(dòng)提示功能實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-02-02bootstrap select2 動(dòng)態(tài)從后臺(tái)Ajax動(dòng)態(tài)獲取數(shù)據(jù)的代碼
這篇文章主要介紹了bootstrap select2 動(dòng)態(tài)從后臺(tái)Ajax動(dòng)態(tài)獲取數(shù)據(jù)的代碼,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12Ajax讀取XML實(shí)現(xiàn)動(dòng)態(tài)下拉導(dǎo)航
Ajax讀取XML實(shí)現(xiàn)動(dòng)態(tài)下拉導(dǎo)航...2007-02-02基于Jquery.history解決ajax的前進(jìn)后退問(wèn)題
本文主要給大家介紹基于Jquery.history解決ajax的前進(jìn)后退問(wèn)題,涉及到j(luò)query前進(jìn)后退相關(guān)方面的知識(shí),本文內(nèi)容經(jīng)典,非常具有參考價(jià)值,特此把jquery前進(jìn)后退相關(guān)知識(shí)分享在腳本之家網(wǎng)站供大家參考2015-10-10AJAX入門之深入理解JavaScript中的函數(shù)
AJAX入門之深入理解JavaScript中的函數(shù)...2006-06-06Ajax在請(qǐng)求過(guò)程中顯示進(jìn)度的簡(jiǎn)單實(shí)現(xiàn)
ajax技術(shù)在web應(yīng)用中使用非常頻繁,本文以asp.net MVC為示例,提供一種簡(jiǎn)單的實(shí)現(xiàn)方式。ajax在請(qǐng)求過(guò)程中顯示進(jìn)度條,是怎么實(shí)現(xiàn)的呢?本文通過(guò)代碼和文字說(shuō)明相結(jié)合的方式分享給大家。2015-09-09[ASP.NET AJAX]Function對(duì)象及Type類的方法介紹
[ASP.NET AJAX]Function對(duì)象及Type類的方法介紹...2007-01-01利用AjaxSubmit()方法實(shí)現(xiàn)Form提交表單后回調(diào)功能
ajaxSubmit()方法是JQuery Form表單插件中的方法,使用時(shí),需要在jsp或者h(yuǎn)tml頁(yè)面上,引入JQuery庫(kù)和Form插件。接下來(lái)通過(guò)本文給大家分享通過(guò)AjaxSubmit()方法實(shí)現(xiàn)Form提交表單后回調(diào)功能,感興趣的朋友跟隨腳本之家小編一起看看吧2018-05-05