XMLHttpRequest Properties: responseText

By: Dusty Arlia
Published on Friday, November 07, 2014 at 2:59 PM
Last Updated on Sunday, July 19, 2015 at 10:28 AM
Total Updates: 2

The responseText property of the XMLHttpRequest JavaScript object holds the body of the HTTP response. The encoding of this property value is Unicode UTF-8 by default if there was no Content-Encoding HTTP header in the HTTP response to specify a different encoding.

If the readyState property has a value less than 3 or a value of UNSENT, OPENED, or HEADERS_RECEIVED, then this property will have an empty string value. If the readyState property has a value of 3 or a value of LOADING, then this property's value will only be the portion of the HTTP response body that it has received so far.

The responseText property will only have the full body of the HTTP response if the readyState property has the value of 4 or DONE.