HTML and CSS Reference
In-Depth Information
TABLE 3-4 Available methods of the XMLHttpRequest object
Method
Description
Cancels the current request
Abort
Gives a complete list of response headers
getAllResponseHeaders
Returns the specific response header
getResponseHeader
Makes the HTTP request and receives the response
Send
Adds a custom HTTP header to the request
setRequestHeader
Sets properties for the request such as the URL, a user name, and a password
Open
TABLE 3-5 Available properties of the XMLHttpRequest object
Property
Description
Gets the current state of the object
readyState
Gets the response returned from the server
Response
Gets the response body as an array of bytes
responseBody
Gets the response body as a string
responseText
Gets the data type associated with the response, such as blob , text , array-
buffer , or document
responseType
Gets the response body as an XML DOM object
responseXML
Gets the HTTP status code of the request
Status
Gets the friendly HTTP text that corresponds with the status
statusText
Sets the timeout threshold on the request
Timeout
Specifies whether the request should include user credentials
withCredentials
In its simplest form, a request to the server using the XMLHttpRequest object looks like
this:
<script>
$("document").ready(function () {
$("#btnGetXMLData").click(function () {
var xReq = new XMLHttpRequest();
xReq.open("GET", "myXMLData.xml", false);
xReq.send(null);
$("#results").text(xReq.response);
});
});
</script>
 
Search WWH ::




Custom Search