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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:20:44+00:00 2026-05-23T09:20:44+00:00

From the reference I read in MDN, it says If TRUE (the default), the

  • 0

From the reference I read in MDN, it says

If TRUE (the default), the execution of the JavaScript function will continue while the response of the server has not yet arrived.

This is the A in AJAX.

I have been using AJAX but then I was a little confused when I read that. I think the problem may be that I am not understanding AJAX concept clearly. I know of course AJAX does not refresh the page which means the connection to the server and the response are completely done in the background.

But what I can imagine happening according to that reference is that if I have a code like this in my JavaScript:

//true, therefore process the function while server retrieves url
var xmlResponse;
var url = "http://example.com/file.xml";
xml_req.open("GET", url, true); 

xml_req.onreadystatechange = function() {
     if(xml_req.readyState == 4 && xml_req.status == 200) {
        if(xml_req.responseText != null)
             xmlResponse = xml_req.responseXML; //server response may not yet arrive
        else {
             alert("failed");
             return false;
        }
     };
xml_req.send(null);

Doesn’t that mean xmlResponse could be undefined in the sense that the server is still retrieving the data? Could somebody explain what really is the flow of the execution in AJAX technology? Thanks in advance.

  • 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-23T09:20:45+00:00Added an answer on May 23, 2026 at 9:20 am

    I wrote a more detailed article here, but this is the basic idea.

    Setting it to true means you are making an asynchronous request. That means the code does not pause until the http request is complete. A synchronous call locks up the browser so nothing else runs. That can cause problems, so people prefer asynchronous.

    The XHR object updates us on what it is doing. It gives us the updates with the onreadystatechange event. We register a function with it so we can keep track of its status. The onreadystatechange gets called 4 times. Each with a different state

    0 = uninitialized
    1 = loading
    2 = loaded
    3 = interactive
    4 = complete
    

    The data is available to us when the readystate is 4.

    Now in the code you posted, it is checking for the complete state and it makes sure that the status is 200 [ok]

    if(xml_req.readyState == 4 && xml_req.status == 200){
    

    The value for xmlResponse will be undefined if you try to use it somewhere else in the code before it is returned. An example

    ml_req.send(null);
    alert(xmlResponse );
    

    One of the very first articles on the XMLHttpRequest article might be a good read for you. Apple Article on xmlhttpreq

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

Sidebar

Related Questions

If you return a value (not a reference) from the function, then bind it
The goal: To create a .NET dll i can reference from inside SQL Server
We know from the C# specification that reference read/writes are atomic. In a statement
I read from sun website that for every reference jvm is creating one immutable
Using a reference from... http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx I have a serializable generic dictionary. One thing I
If I add a web reference from a .NET 1.1 client to a WCF
Is there any way to add reference from one winforms to another winforms?? There
We have a product that uses a Reference from a 3rd party supplier. With
I have a WCF service that I have to reference from a .net 2.0
I know how to tell Castle Windsor to resolve a reference from a factory's

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.