Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3600188
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:27:49+00:00 2026-05-18T20:27:49+00:00

Have you ever used an XHR object to intercept onreadystatechange with a readyState different

  • 0

Have you ever used an XHR object to intercept onreadystatechange with a readyState different from "4" (complete) ?

I’m curious to know if you ever trigger a function with the possible different values.
I cannot imagine a real use of the others states. Are they somewhat useful to do something?

Can give some practical examples if any ?

I’m talking about these:

  • 0: request not initialized
  • 1: server connection established
  • 2: request received
  • 3: processing request
  • 4: request finished and response is ready
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:27:49+00:00Added an answer on May 18, 2026 at 8:27 pm

    I use it on an intranet I have developed for notification purposes.
    By intercepting the state 3 I can notify the user that the request started.

    I also use it to time the requests transmission times. I display the time elapsed between states 3 and 4.

    Since I use MooTools I extended the Request class to fire the onStateChange event:

    var EarlyRequest = new Class({Extends: Request,
     onStateChange: function() {
      this.fireEvent("onStateChange", [this.xhr.readyState]);
      this.parent();
     }
    });
    

    On an additional note. The definitions of the states that you posted (from w3cschools) are misleading, these are clearer to me (from http://www.w3.org/TR/XMLHttpRequest/#states):

    • UNSENT (numeric value 0)
      The object has been constructed.

    • OPENED (numeric value 1)
      The open() method has been successfully invoked. During this state request headers can be set using setRequestHeader() and the request can be made using the send() method.

    • HEADERS_RECEIVED (numeric value 2)
      All redirects (if any) have been followed and all HTTP headers of the final response have been received. Several response members of the object are now available.

    • LOADING (numeric value 3)
      The response entity body is being received.

    • DONE (numeric value 4)
      The data transfer has been completed or something went wrong during the transfer (e.g. infinite redirects).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have you ever used an XHR object to intercept onreadystatechange with a readyState different
I have only ever used VSS (uggh, I know) and Team Foundation Server for
I am using wxWidgets where, if you have ever used it, you will know
For those of you who have ever used Microsoft Excel in a manner that
Have you ever used lazy C++? I am trying to create .CPP files out
If you have ever used a new release of either Chrome or Safari, you
This is a very simple task in every language I have ever used, but
I have been coding since a long time but I have never ever used
If any of you have ever used wmd markdown editor (which is like the
Have you ever used jQuery Grid with google maps?, it seems like jQuery grid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.