In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the AJAX XMLHttpRequest objects". In daily operation, I believe many people have doubts about what are the problems with the AJAX XMLHttpRequest object. Xiaobian consulted all kinds of information and sorted out simple and easy to use operation methods. I hope to help you answer the doubts about "what are the AJAX XMLHttpRequest objects"! Next, please follow the small series to learn together!
What is an AJAX XMLHttpRequest object?
The XMLHttpRequest object is not yet standardized, but the W3C has begun standardization work, and the content described in this article is based on standardized working drafts.
For newer browsers, the syntax for creating an XMLHttpRequest object:
?
1
var xmlhttp=new XMLHttpRequest();
For older IE browsers (IE5 and IE 6), use ActiveX to create:
?
1
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
Code for creating XMLHttpRequest objects compatible with all browsers:
script type="text/javascript">
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");
}
/script>
If you are worried about browser errors, try.. catch instead of if... else, as follows:
What is an AJAX XMLHttpRequest object?
script type="text/javascript">
var xmlhttp;
try{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}catch(e){
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
/script>
The XMLHttpRequest object has multiple properties and methods, as well as an event handler.
XMLHttpRequest object properties and methods
property specification
readyState The status of the HTTP request. When an XMLHttpRequest is first created, the value of this attribute starts at 0 and increases to 4 until the full HTTP response is received.
responseText Data received from the server (excluding headers)(parsed as a string).
responseXML Data received from the server (excluding headers)(parsed to XML and returned as Document objects).
status The HTTP status code returned by the server. For example, 200 means success and 404 means "Not Found" error.
statusText This attribute specifies the HTTP status code of the request by name rather than number. That is, it is "OK" when the status is 200 and "Not Found" when the status is 404.
event handler description
onreadystatechange Event handler function called each time the readyState property changes.
method statements
abort() cancels the current response, closes the connection and ends any unfinished network activity.
getAllResponseHeaders() Returns the HTTP response header (all headers) as a string.
getResponseHeader() returns the value of the specified HTTP response header, whose argument is the name of the HTTP response header to return. The header name can be specified in any case, and comparisons with response headers are case-insensitive.
open() initializes HTTP request parameters, such as URL and HTTP method, but does not send the request.
send() sends an HTTP request, using the parameters passed to the open() method, and the optional request body passed to the method.
setRequestHeader() Sets or adds an HTTP request to an open but unsent request.
At this point, the study of "what are the AJAX XMLHttpRequest objects" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.