Java Reference
In-Depth Information
The
XMLHttpRequest
object has a number of properties that can be used to process the
response:
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
• 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.