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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:20:41+00:00 2026-06-05T17:20:41+00:00

In the following piece of JavaScript code, i’m executing GetData.php using AJAX. However, when

  • 0

In the following piece of JavaScript code, i’m executing GetData.php using AJAX. However, when i remove the comments to see the request object’s state property, it turns up as undefined, although the PHP script is getting executed properly and my page is changing as i want it to. But i still need the state property. Any clue on what’s going on here ?

 function refreshPage()
 {
    var curr = document.getElementById('list').value;
    var opts = document.getElementById('list').options;
    for(var i=0;i<opts.length;i++)
     document.getElementById('list').remove(opts[i]);
    var request = new XMLHttpRequest();
    request.onreadystatechange=
    function()
    {
        if(request.readyState == 4)
        {
          //alert(request.state);
          //if(request.state == 200)
          {
            fillOptions();
            var exists = checkOption(curr);
            var opts = document.getElementById('list').options;
            if(exists == true)
            {
                for(var i=0;i<opts.length;i++)
                  if(curr == opts[i])
                  {
                    opts[i].selected = true;
                    break;
                  }
            }
            else
            {
                opts[0].selected = true;
            }
            refreshData();
          }
          /*else
          {
             alert(request.responseText);
             //document.close();    
          }*/
       }
    }
    request.open("GET","GetData.php?Address=" + address + "&Port=" + port,true);
    request.send();
 }
  • 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-06-05T17:20:43+00:00Added an answer on June 5, 2026 at 5:20 pm

    Do you mean request.status not request.state?
    Try changing it to the .status and it should work just fine 🙂

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

Sidebar

Related Questions

I'm a JavaScript beginner and managed to piece together to following code. It gets
I found the following piece of JavaScript code (maybe here at Stack Overflow?) for
I have written the following piece of code in my view page <script type=text/javascript>
Consider the following piece of code: <html><head></head> <body> <script type=text/javascript> var outside_scope = outside
i have the following piece of code in the page HEAD: <script type=text/javascript> $(document).ready(function(){
I'm using the following piece of code in my webpage to change the class
I have the following piece of code, inside a php script foreach( $results as
Have the following piece of javascript over on http://jsfiddle.net/mhenrixon/zPLgS/16/ and its working fine in
I've come across the following piece of JavaScript and would like to know what
I wanted to know if anybody can explain me the following piece of Javascript

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.