AJAX Responses Quiz

Quiz 2 5 questions

Prerequisites for the quiz

  1. The chapter on AJAX Response Handling
  2. How to work with HTML Responses
  3. The concept of Response Headers

Are you ready?

5 questions to solve

  1. This quiz goes to full-screen once you press the Start button.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
What is the purpose of the responseText property?
responseText holds the body content of the response. See AJAX Response Handling for more info.
How can we retrieve a parsed version of an XML response?
The property responseXML holds a parsed XMLDocument object for the returned XML response.
What is the value of resp in the following code?
var xhr = new XMLHttpRequest();

// request the HTML file foods.html
xhr.open("GET", "foods.html", true);

xhr.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200) {
        var resp = this.responseXML;

Choice (A) is incorrect here, because to get a parsed HTML response we need to set the responseType property to "document". See AJAX HTML Responses for more info.
What does the method getResponseHeader() do?
getResponseHeader() returns the value of a given header; thus going with choice (A) here. See AJAX Response Headers for more info.
What do we need to do in order to get an HTML document as a parsed Document object?
See AJAX HTML Responses for more info.

"I created Codeguage to save you from falling into the same learning conundrums that I fell into."

— Bilal Adnan, Founder of Codeguage