XML AJAXLesson 24Free preview
AJAX Response
This lesson is part of XML · All levels
Summary
Once the server responds, the result is read through the responseText property for text or responseXML for XML documents. Callback onreadystatechange is used to ensure the status is complete (readyState 4) and HTTP successful (status 200) before data is displayed. The response is also often converted to an object with JSON.parse before use.
Key points
- ResponseText contains a response as a string
- ResponseXML contains a response in the form of an XML DOM tree
- Read the response only when readyState 4 and status 200
- JSON.parse converts the JSON string into a JavaScript object
- Response data should be validated before display
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.