AJAX-create an XMLHttpRequest object

Source: Internet
Author: User
XMLHttpRequest object

All modern browsers support XMLHttpRequest objects (IE5 and IE6 use ActiveXObject ).

XMLHttpRequest is used to exchange data with the server in the background. This means that you can update a part of a webpage without reloading the entire webpage.

Create an XMLHttpRequest object

All modern browsers (IE7 +, Firefox, Chrome, Safari, and Opera) have built-in XMLHttpRequest objects.

Syntax for creating an XMLHttpRequest object:
Variable = new XMLHttpRequest ();
Earlier versions of Internet Explorer (IE5 and IE6) Use ActiveX objects:
Variable = new ActiveXObject ("Microsoft. XMLHTTP ");

To handle all modern browsers, including IE5 and IE6, check whether the browser supports XMLHttpRequest objects. If yes, create an XMLHttpRequest object. If not, ActiveXObject is created:

Var xmlhttp; if (window. XMLHttpRequest) {// code for IE7 +, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest ();} else {// code for IE6, IE5 xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");}
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.