jQuery in Action
220
CHAPTER 8
Talk to the server with Ajax
1
Table 8.1 XHR methods and properties
Methods
Description
abort()
Causes the currently executing request to be cancelled.
getAllResponseHeaders()
Returns a single string containing the names and values of all
response headers.
response headers.
getResponseHeader(name)
Returns the value of the named response header.
open(method,url,async,
username,password)
Sets the method and destination URL of the request. Option-
ally, the request can be declared synchronous, and a username
and password can be supplied for requests requiring container-
based authentication.
ally, the request can be declared synchronous, and a username
and password can be supplied for requests requiring container-
based authentication.
send(content)
Initiates the request with the specified (optional) body content.
setRequestHeader(name,value)
Sets a request header using the specified name and value.
Properties
Description
onreadystatechange
Assigns the event handler used when the state of the
request changes.
readyState
An integer value that indicates the state of the request
as follows:
0--Uninitialized
1--Loading
2--Loaded
3--Interactive
4--Complete
responseText
The body content returned in the response.
responseXML
If the body content is XML, the XML DOM created from the
body content.
body content.
status
Response status code returned from the server. For example:
200 for success or 404 for not found. See the HTTP
200 for success or 404 for not found. See the HTTP
Specification
1
for the full set of codes.
statusText
The status text message returned by the response.
1
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10
1