JavaScript AJAX Basics (retiring) Programming AJAX Parsing JSON Data

Krista Prenesti
Krista Prenesti
4,136 Points

Why does .responseText give OK in an alert but all of the data in the example? What is responseText?

Why does .responseText give OK in an alert but all of the data in the example? What is responseText?

3 Answers

The XMLHttpRequest.responseText property returns a DOMString that contains the response to the request as text. From https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseText

In other words, the XMLHttpRequest response property will return the response code, ie. 200 for OK or 404 for page not found, while the responseText property will return the text, ie OK or Page Not Found.

Emmanuel Plouvier
Emmanuel Plouvier
11,919 Points

Hi,

I'm not to totaly sure I understand your question but : responsText are a property of the obect was returned by an AJAX request.

I hope i can help you.

Krista Prenesti
Krista Prenesti
4,136 Points

Nevermind. I was confusing responseText with statusText. Doh!