Java Reference
In-Depth Information
The XMLHttpRequest object has a number of properties that can be used to process the
• The status property returns the HTTP status code. This will usually be 200 if
the response was successful, 201 if a resource was created, or 204 when the re-
quest is successful but no content is returned.
• The response property returns the response sent back from the server. This can
be text, HTML, JSON, a document, or a file.
• The responseText property returns a string representation of the response or
null if nothing is returned. This can then be inserted into the document using
the innerHTML property of an element or parsed into a JavaScript object if it's a
JSON string.
• The responseXML property returns a document object that can then be parsed
using the DOM methods that we saw in Chapter 6 .
• The responseType property returns a string indicating the type of data con-
tained in the response.
Warning: Watch Out for Cookies
Each Ajax request is still a full HTTP request, so they will also download
the cookies associated with that request. Even though cookies have a size
limit they soon add up, causing each Ajax request to end up being larger
than expected, making them slower and more cumbersome to deal with.
Search WWH ::

Custom Search