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

statusText property (XMLHttpRequest)

Browser support:
Returns a string that represents the status of the request in a friendly form.
To get the status code of a request, use the status property. The page for the status property contains descriptions about the possible status codes that are similar to the statusText property.


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

Possible values:

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

Example HTML code 1:

This example illustrates the use of the statusText 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 () {
            var output = document.getElementById ("output");
            if (httpRequest.readyState == 0 || httpRequest.readyState == 4) {
                output.innerHTML += "status information: <span style='color:blue'>" + httpRequest.statusText + "</span><br />";
                if (IsRequestSuccessful (httpRequest)) {    // defined in ajax.js
                    output.innerHTML += "data has been received: <span style='color:blue'>" + httpRequest.responseText + "</span><br />";
    <button onclick="SendRequest ()">Test statusText property</button>
    <br /><br />
    <div id="output" style="width:420px; height:200px; overflow:auto; border:1px solid #000000; background-color:#f5e4b1;"></div>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content