You are here: Reference > JavaScript > client-side > xml handling > properties > status (XMLHttpRequest)

status property (XMLHttpRequest)

Browser support:
Returns an integer that represents the status code of the request.
To get the status of a request in a friendly form, use the statusText property.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Integer that represents the status.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the status property:
    <script type="text/javascript" src="ajax.js"></script>
    <script type="text/javascript">
        var httpRequest = null;

        function SendRequest () {
            if (!httpRequest) {
                httpRequest = CreateHTTPRequestObject ();   // defined in ajax.js
            if (httpRequest) {          
                    // The requested file must be in the same domain that the page is served from.
                var url = "response.txt";
       ("GET", url, true);    // async
                httpRequest.onreadystatechange = OnStateChange;
                httpRequest.send (null);

        function OnStateChange () {
            if (httpRequest.readyState==4) {
                if (IsRequestSuccessful (httpRequest)) {    // defined in ajax.js
                    alert (httpRequest.responseText);
                else {
                    alert ("Operation failed.");

    <button onclick="SendRequest ()">Test status property</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content