Ajaxphp brushless New Level 2 linkage drop-down menu (provincial/municipal linkage) source code

Source: Internet
Author: User
Ajax. js/*** ajax brushless New Level 2 linkage drop-down menu (provincial/municipal linkage) ** @ authorarcowarcow@126.com * @ version1.0 * @ lastupdate2005-12-29 **/varhttp_request = false; functionsend_request

Ajax. js

/**
* Ajax No-refreshing secondary linkage drop-down menu (provincial/municipal linkage)
*
* @ Author arcow <Arcow@126.com>
* @ Version 1.0
* @ Lastupdate 2005-12-29
*
*/
Var http_request = false;
Function send_request (url, method) {// initialize, specify the processing function, and send the request function
Http_request = false;
// Initialize the XMLHttpRequest object
If (window. XMLHttpRequest) {// Mozilla browser
Http_request = new XMLHttpRequest ();
If (http_request.overrideMimeType) {// Set the MiME type
Http_request.overrideMimeType ('text/XML ');
}
}
Else if (window. ActiveXObject) {// IE browser
Try {
Http_request = new ActiveXObject ('msxml2. xmlhttp ');
} Catch (e ){
Try {
Http_request = new ActiveXObject ('Microsoft. xmlhttp ');
} Catch (e ){}
}
}
If (! Http_request) {// exception. An error occurred while creating the object instance.
Window. alert ('cannot create XMLHttpRequest object instance .');
Return false;
}
Switch (method ){
Case 1: http_request.onreadystatechange = processRequest1; break; // select the control function
Case 2: http_request.onreadystatechange = processRequest2; break;
Case 3: http_request.onreadystatechange = processRequest3; break;
}
// Determine the method and URL for sending the request and whether to synchronously execute the following code
Http_request.open ('GET', url, true );
Http_request.send (null );
}
// Function for processing the returned information
Function processRequest1 () {// controls function 1 and transfers it to the province
If (http_request.readyState = 4) {// identifies the object status
If (http_request.status = 200) {// The information has been returned successfully. start to process the information.
Document. getElementById ('statustxt '). innerHTML = '';
AddOptionGroup ('Province ', http_request.responseText );
} Else {// The page is abnormal.
Alert ('The page you requested has an exception. ');
}
} Else {// as long as the read is not completed
Document. getElementById ('statustxt '). innerHTML = 'regular reading ...... ';
}
}
 
Function processRequest2 () {// controls function 2 and transfers it to the city.
If (http_request.readyState = 4) {// identifies the object status

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.