Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the XMLHTTPRequest object in AJax

Shulou Source: shulou.com Published: 2022-06-03 05:38:33 10月15日 Update

This article mainly shows you "what is the XMLHTTPRequest object in AJax", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the XMLHTTPRequest object in AJax" this article.

1. What is XMLHttpRequest

Definition: XMLHttp is a set of API that can transmit or receive XML and other data through http protocol in Javascript, VbScript, Jscript and other scripting languages. The greatest use of XmlHttp is that it can update parts of a web page without having to refresh the entire page (this is one of the biggest features of AJax).

2. Create a XMLHttpRequest object

Before we can use the XMLHTTPRequest object to send the request and process the response, we must create a XMLHTTPRequest object with javascript. IE implements XMLHTTPRequest as an ActiveX object, while other browsers [such as Firefox/Safari/Opear] implement it as a native javascript object. Please look at the following example

The copy code is as follows:

Var xmlhttp

/ / create a XMLHTTPRequest object

Function createXMLHTTPRequest () {

If (window.ActiveXObject) {/ / determine whether the ActiveX control is supported

Xmlhttp = new ActiveObject ("Microsoft.XMLHTTP"); / / creation method supported by IE browser

}

Else if (window.XMLHTTPRequest) {/ / determines whether to implement XMLHTTPRequest as a local javascript object

Xmlhttp = new XMLHTTPRequest (); / / creation methods supported by browsers such as FireFox,Opera

}

}

3. Attributes and methods

Because there is a lot of content involved, and I am also learning, so I also learn with reference to other people's examples, so paste other people's good things up here for review.

The copy code is as follows:

Description DEMO of the XMLHTTPRequest object

Tags: Properties objects data methods comments syntax information server status services documents characters strings this method encoding content variables processing validation code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MySQL Shulou Technology Huawei Xiaomi