Ajax reads data on demand generate subordinate menu _ajax related

Source: Internet
Author: User
Jilian.htm
Copy Code code as follows:

<script language= "JavaScript" >
var Http_request=false;
function send_request (URL) {//initialization, specifying handler functions, sending requested functions
Http_request=false;
Start initializing the XMLHttpRequest object
if (window. XMLHttpRequest) {//mozilla browser
Http_request=new XMLHttpRequest ();
if (http_request.overridemimetype) {//Set MIME type
Http_request.overridemimetype ("text/html");
}
}
else if (window. ActiveXObject) {//ie browser
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) {//exception, failed to create object instance
Window.alert ("Cannot create XMLHttpRequest object instance");
return false;
}
Http_request.onreadystatechange=processrequest;
Determine how and when the request is sent and whether the next code is executed synchronously
Http_request.open ("Get", url,true);
Http_request.send (NULL);
}
Functions that process return information
function ProcessRequest () {
if (http_request.readystate==4) {//Judge object state
if (http_request.status==200) {//information has been successfully returned, start processing information
document.getElementById (Currentpos). Innerhtml=http_request.responsetext;
}
else{//page is not normal
Alert ("The page you requested has an exception");
}
}
}
function Showroles (obj) {
document.getElementById (obj). parentnode.style.display= "";
document.getElementById (obj). innerhtml= "reading data ..."
Currentpos=obj;
Send_request ("jilian_data.asp?playpos=" +obj);
}
</script>

<table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 ">
<tr>
&LT;TD height= ">"
<a href= "javascript:void (0)" onclick= "Showroles (' Pos_1 ')" > manager's Office
</a>
</td>
</tr>
<tr style= "Display:none" >
&LT;TD height= "id=" Pos_1 > </td>
</tr>
<tr>
&LT;TD height= ">"
<a href= "javascript:void (0)" onclick= "Showroles (' pos_2 ')" > Development Department </a>
</td>
</tr>
<tr style= "Display:none" >
&LT;TD id= "pos_2" height= "> </td>
</tr>
</td>
</table>

Jilian_data.asp
Copy Code code as follows:

<% @LANGUAGE = "VBSCRIPT"  codepage= "936"%>
<%
Playpos=request ("Playpos")
if playpos= "Pos_1"  then
Response.Write ("  jingli<br >   deputy General Manager ")
End if
if playpos=" pos_2 " then
Response.Write ("    chief Engineer <br>   Software Engineer ")
End if
%>



Related Article

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.