Share via


Sys.Net.XmlHttpExecutor responseData Property

Gets the text representation of the response body.

Note

To get or set property values for client API properties, you must call property accessor methods that are named with the get_ and set_ prefixes. For example, to get or set a value for a property such as cancel, you call the get_cancel or set_cancel methods.

var responseData = MyExecutor.get_responseData();

Exceptions

Exception type

Condition

Sys.InvalidOperationException

The responseData property was accessed outside the event handler.

-or-

The responseData property was accessed after the completed event occurred.

Return Value

The text representation of the response body, if there is one; otherwise, an empty string ("").

Remarks

If the Web request completed successfully, you can get the value of the responseData property to get the text representation of the response body. If there is no response body, this property returns an empty string ("").

The executor does not attempt any character conversions on the response data. Instead, it relies on the browser's XMLHTTP implementation for Unicode conversion behavior. For Microsoft Internet Explorer, the response is returned as UTF-8 text unless the server has included a byte order marker (BOM) at the start of the response to indicate a different variation of Unicode.

You can use the responseData property only in code that is running inside a completed event handler, or running in the call stack of the completed event handler. An exception is thrown if you use the responseData property when the executor did not return valid response data, or if the response is not yet available (if the responseAvailable property returns false). An exception is also thrown if you use the responseData property after the completed event has occurred. This is because the executor has released its reference to the browser's XMLHTTP object.

Example

The following example shows how to use the responseData property. This code is part of a complete example found in the Sys.Net.XmlHttpExecutor class overview.

// Display Web request body.
resultElementId.innerHTML += "Body: <br/>";
resultElementId.innerText += 
    executor.get_responseData();

See Also

Reference

Sys.Net.WebRequestManager Class

Sys.Net.WebRequestExecutor Class

Sys.Net.XMLHttpExecutor Class