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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:38:06+00:00 2026-06-05T06:38:06+00:00

I have a simple HTML file, that gets data from the server and outputs

  • 0

I have a simple HTML file, that gets data from the server and outputs it:

<html>
    <head>
        <script type="text/javascript">
        var xmlhttp = new XMLHttpRequest();
        function startRequest() {
            xmlhttp.onreadystatechange = handleStateChange;
            xmlhttp.open("GET", "http://new-host-2.home/test.html", true);
            xmlhttp.send(null);
        }
        function handleStateChange() {
            if (xmlhttp.readyState == 4) {
                if (xmlhttp.status == 200) {
                    alert("The server replied with: ", xmlhttp.responseText);
                }
                else {
                    alert(xmlhttp.status);
                }
            }
        }
        </script>
    </head>
    <body>
        <form>
            <input type="button" value="Woooo" onclick="startRequest()"/>
        </form>
    </body>
</html>

The file that is on the server, test.html looks like this:

<h1>Data received!</h1>

I keep getting 0 as a status, despite the fact that in the console, it says everything is fine, and gives a 200 status. When I change if (xmlhttp.status == 200) to if (xmlhttp.status == 0), it just outputs The server replied with:. Why is this? Am I messing something up?
EDIT: It might just be my server, I’m gonna switch to a different one.
The Headers might be helpful:

Response Headers
Accept-Ranges   bytes
Connection  Keep-Alive
Content-Length  13
Content-Type    text/html
Date    Sat, 09 Jun 2012 14:17:11 GMT
Etag    "267749b-d-4c20a6d0ef180"
Keep-Alive  timeout=15, max=100
Last-Modified   Sat, 09 Jun 2012 13:52:22 GMT
Server  Apache/2.2.19 (Unix) DAV/2
Request Headers
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection  keep-alive
Host    new-host-2.home
Origin  null
User-Agent  Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0
  • 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-05T06:38:08+00:00Added an answer on June 5, 2026 at 6:38 am

    alert function only takes one parameter, you’re passing 2.

    Give this a shot:

    var xmlhttp = new XMLHttpRequest(); 
    function startRequest() { 
        xmlhttp.onreadystatechange = function()
        {
            if (xmlhttp.readyState==4)
            {
                if(xmlhttp.status==200)
                    alert("The server replied with: " + xmlhttp.responseText);
                else
                    alert(xmlhttp.status);
            }
        }
        xmlhttp.open("GET", "http://new-host-2.home/test.html", true); 
        xmlhttp.send(); 
    } 
    

    If it still doesn’t work, it might be a security issue: http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/282972/why-am-i-getting-xmlhttprequest.status0

    If it works in Safari, then try removing the domain in your request to make the path relative. Firefox might be thinking that you’re attempting some cross-domain stuff.

    var xmlhttp = new XMLHttpRequest(); 
    function startRequest() { 
        xmlhttp.onreadystatechange = function()
        {
            if (xmlhttp.readyState==4)
            {
                if(xmlhttp.status==200)
                    alert("The server replied with: " + xmlhttp.responseText);
                else
                    alert(xmlhttp.status);
            }
        }
        xmlhttp.open("GET", "/test.html", true); 
        xmlhttp.send(); 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have this simple piece of HTML code: <div> <input type=file name=english-file /> </div>
I have three simple html or php file that I'm going to create. What
I have a simple place-holder html-file that I would want to use the header
I have a simple HTML file which references .gadget so that it can be
I have a mail.php file that gets called by an ajax script. For completeness,
can anyone help? I have a simple html file which i am filling via
Does symfony2 have simple button type(not submit or file) for forms? I looked there(http://symfony.com/doc/current/reference/forms/types.html)
Simple problem: By default, for example, when I have a file like this: <html>
I have simple html code that plays YouTube video after click on the image:

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.