Multi-browser compatible Ajax operations

Source: Internet
Author: User

 

VaR xmldoc, X;

Function xmlhttp_async (URL, onready ){

If (url = NULL | url = "") return false;
If (window. XMLHttpRequest ){
X = new window. XMLHttpRequest ();
If (X. overridemimetype) // ie Error
X. overridemimetype ('text/xml'); // if this parameter is not specified, safafi, such as aspx, or chrome, may be null.
// Https://developer.mozilla.org/cn/AJAX/%e5%bc%80%e5%a7%8b this page has good content
}
Else if (window. activexobject ){
X = new activexobject ("Microsoft. XMLHTTP ");
}
X. Open ("get", URL, true );
X. Send (null );
If (onready! = ""){
X. onreadystatechange = function (){
If (X. readystate = 4 & (X. Status = 200 | X. Status = 304 )){
Xmldoc = x. responsexml; // you can obtain it from the outside.
Eval (onready );
}
}
}
}

 

Call xmlhttp_async (XML address, read and execute the function)

Read null values in Firefox using xmldoc. getelementsbytagname ("XXXX") [I]. firstchild. Data

 

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.