ajax-Creating XMLHttpRequest Objects

Source: Internet
Author: User

ajax-Creating XMLHttpRequest Objects

1.XMLHttpRequest is the basis of Ajax, all now supported by browsers, for exchanging data in the background with the server, which means that the entire page can be updated without loading the entire page.

2. All modern browsers support XMLHttpRequest objects.

Create XMLHttpRequest object syntax: xmlhttp = new XMLHttpRequest ();

3. For all modern browsers, including IE5,IE6. First check whether the XMLHttpRequest object is supported, create the XMLHttpRequest object if supported, and create ActiveXObject if not supported.

The old version of IE (5,6) uses the ActiveX object syntax: XMLHTTP = new ActiveXObject ("Microsoft.XMLHTTP");


4. in order to save time by writing Ajax, you can package object detection into a good function to take

function Gethttpobjet () {
var xmlhttp = false;
if (window. XMLHttpRequest) {//code for ie7+, Firefox, Chrome, Opera, Safari
Xmlhttp=new XMLHttpRequest ();
}else {//code for IE6, IE5
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}
return xmlhttp;

ajax-Creating XMLHttpRequest Objects

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.