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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:07:27+00:00 2026-05-19T22:07:27+00:00

Hi im currently making a xmhhttp request, but the site takes some time to

  • 0

Hi im currently making a xmhhttp request, but the site takes some time to load, so I only get the ReadyState = 3 and status = 200. So I need something that waits until the readystate = 4, but I want to limit this function so that it only checks once a second if the readystate = 4, else do nothing.

How can such a delay function look like?

   if (xmlhttp.readyState==4 && xmlhttp.status==200)//Add the delay here so that the else doesn't occur
    {
    var txt=xmlhttp.responseText;
    .....
  else {

    document.write("status: " + xmlhttp.readyState + " " + xmlhttp.status);
  }
  • 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-19T22:07:28+00:00Added an answer on May 19, 2026 at 10:07 pm

    We can write a function for checking the state of your xmlhttp-object:

    var checkState = function(xmlhttp, callback) {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        callback(whatever, arguments, that, you, want, to, send);
      } else {
        // Check back again 1 sec later
        setTimeout(checkState, 1000);
      }
    };
    

    Then you can use it like this:

    checkState(xmlhttp, function(whatever, arguments, you, need) {
      // the code here will be run when the readyState is 4 and the status is 200
    });
    

    Two things though:

    • The checkState function will return regardless of the readyState, so make sure you only do things that depend on it in the callback, not after.
    • If the readyState and status never get your desired values, you’re out of luck (but you could extend the function to accept a second callback that will handle a timeout case).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently making a method to load in a noisy heightmap, but lack
I'm currently making a GWT project where I display some HTML in a RichTextArea
I'm currently making some system that will gather statistical reports from different sites, for
Hi i am currently making a demo site from just pure html/css/javascript usually i
I am currently making a facebook app and am having some problems with permissions.
currently making a SOAP request using Java's SOAPConnectionFactory and SOAPConnection 's .call() method, which
I'm currently making a webpage and I have run in to some problems with
I am currently making a time-clock system that is inside of a custom-built application
I'm currently making a xpath search, I've got the the search working but I
I'm making a mobile site using Dashcode to help me creating better UIs, but

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.