An important technology (tool) used when designing AJAX is the XMLHTTPRequest object. Here Tsunami will share with you some of my information on learning the XMLHTTPRequest object. The information in this article was collected online by Tsunami when he was studying. If you have driven it, let’s deepen your impression! (If you feel that your copyright has been infringed, please contact tsunami. (haixiao_yao[at]yahoo.com.cn))
1. What is the XMLHTTPRequest object?
The most common definition is: XmlHttp is a set of APIs that can transmit or receive XML and other data through the http protocol in JavaScript, VbScript, Jscript and other scripting languages. The biggest use of XmlHttp is that it can update part of the content of a web page without refreshing the entire page. (This function is one of the major features of AJAX:))
Explanation from MSDN: XmlHttp provides a protocol for the client to communicate with the http server. The client can send a request to the http server through the XmlHttp object (MSXML2.XMLHTTP.3.0) and use the Microsoft XML Document Object Model Microsoft? XML Document Object Model (DOM) to process the response.
Let me digress here. In fact, this thing has appeared a long time ago, but the browser support was not enough in the past. It was only supported in IE, so most WEB programmers did not use it very much, but now the situation has happened. Big changes, Mozilla and Safari adopted it as a de facto standard, and mainstream browsers began to support the XMLHTTPRequest object. But what needs to be emphasized here is that XMLHTTPRequest is not yet a W3C standard, so the performance on different browsers is slightly different.
2. Create an XMLHTTPRequest object
By the way, speaking of differences, let’s take a look at how to declare (use) it. Before using the XMLHTTPRequest object to send requests and process responses, we must To create an XMLHTTPRequest object using javascript. (IE implements XMLHTTPRequest as an ActiveX object, and other browsers [such as Firefox/Safari/Opear] implement it as a native javascript object). Let’s take a look at how to use javascript to create it: