Sys.Net.XmlHttpExecutor statusCode Property

Gets the status code of the browser's XMLHTTP object.

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 statusCode = MyExecutor.get_statusCode();

Exceptions

Exception type

Condition

Sys.InvalidOperationException

The statusCode property was accessed outside the event handler.

-or-

The statusCode property was accessed after the completed event occurred.

Return Value

The status code of the browser's XMLHTTP object as a string (for example, "200 OK.

The request has succeeded."). For more information, see About Native XMLHTTP.

Remarks

You can use the statusCode 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 statusCode property when the executor did not return successfully, or if the responseAvailable property returns false. An exception is also thrown if you use the statusCode 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 access status information by using statusCode property. This code is part of a complete example found in the Sys.Net.XmlHttpExecutor class overview.

// Display the Web request status. 
resultElementId.innerHTML +=
   "Request Status: [" + executor.get_statusCode() + " " + 
             executor.get_statusText() + "]" + "<br/>";

See Also

Reference

Sys.Net.WebRequestManager Class

Sys.Net.WebRequestExecutor Class

Sys.Net.XMLHttpExecutor Class