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 4109760
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:50:32+00:00 2026-05-20T21:50:32+00:00

how can i know the readystates of an ajax request through jquery ? In

  • 0

how can i know the readystates of an ajax request through jquery ?
In general, without using jquery, we will send an ajax request like this:

http.open("POST", url, true);

http.onreadystatechange = function() { 
    if(http.readyState == 4 && http.status == 200) {
        // do something
    }
}

So i can easily track the readystate value from 1 to 4 using the above code, and perform necessary action like showing a loading icon when readystate is 1.

But through a jquery ajax call, how can i track the readystate values ?

I am making an ajax call through jquery like this:

$.post('ajax/test.html', function(data) {
  $('.result').html(data);
});
  • 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-20T21:50:33+00:00Added an answer on May 20, 2026 at 9:50 pm

    Have a look at the documentation of $.ajax. You have the possibility to pass different callbacks (maybe not for evert “ready state” but it is enough for an indicator):

    beforeSend(jqXHR, settings) Function
    A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings maps are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request.

    success(data, textStatus, jqXHR) Function, Array
    A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event.

    error(jqXHR, textStatus, errorThrown) Function
    A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". This is an Ajax Event. As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and JSONP requests.

    complete(jqXHR, textStatus) Function, Array
    A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request ("success", "notmodified", "error", "timeout", "abort", or "parsererror"). As of jQuery 1.5, the complete setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event.

    So the best idea would be to show the indicator in the callback passed to beforeSend and hide it in complete.


    Example:

    So you would have to rewrite your code as:

    $.ajax({
      url: 'ajax/test.html',
      type: 'POST',
      beforeSend: function() {
           // show indicator
      },
      complete: function() {
          // hide indicator
      },
      success: function(data) {
          $('.result').html(data);
      }
    });
    

    although I don’t understand why you use POST as your are not sending any data (at least in your example code).

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

Sidebar

Related Questions

I like how this works in Zend Framework. I can know which environment I'm
Using jQuery's $.ajax() function. Wherether the request has been purposely aborted, or if the
I am using jQuery 1.6 and I would like to know and understand how
I can run this code in Android app (using PhoneGap adn jQuery Mobile) but
like in java I have: Class.getSuperClass().getDeclaredFields() how I can know and set private field
Alright, I know questions like this have probably been asked dozens of times, but
I'm experiencing a difficult ajax error in IE9. I will say up-front that this
I would like to know if instead of void function in thread, I can
In jQuery you can use $().jquery; and you can know your framework version, is
The wifi scanning apps like eWifi, WiFiFoFum and so on in Cydia can know

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.