How to create a XMLHttpRequest object
This article mainly introduces the relevant knowledge of how to create XMLHttpRequest objects, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this article on how to create XMLHttpRequest objects. Let's take a look at it.
The core of Ajax is the XMLHttpRequest object.
XMLHttpRequest object
All modern browsers support XMLHttpRequest objects.
The XMLHttpRequest object is used to exchange data with the behind-the-scenes server. This means that parts of the page can be updated without having to reload the entire page.
Create a XMLHttpRequest object
All modern browsers (Chrom, IE7+, Firefox, Safari, and Opera) have built-in XMLHttpRequest objects.
The syntax for creating a XMLHttpRequest is:
Variable = new XMLHttpRequest ()
Older versions of Internet Explorer (IE5 and IE6) use ActiveX objects:
Variable = new ActiveXObject ("Microsoft.XMLHTTP")
To handle all browsers, including IE5 and IE6, check that the browser supports XMLHttpRequest objects. If it is supported, create a XMLHttpRequest object, if not, create an ActiveX object:
Example
Var xhttp
If (window.XMLHttpRequest) {
Xhttp = new XMLHttpRequest ()
} else {
/ / code for IE6, IE5
Xhttp = new ActiveXObject ("Microsoft.XMLHTTP")
}
This is the end of the article on "how to create XMLHttpRequest objects". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to create XMLHttpRequest objects". If you want to learn more, you are welcome to follow the industry information channel.