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

The Archive Base Latest Questions

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

I am following along with a tutorial book on AJAX and I seem to

  • 0

I am following along with a tutorial book on AJAX and I seem to be failing on some basic concept.

Here is the HTML and Javascript I am using (this is saved as ajax.html on my godaddy hosted web server):

<html>
    <head>
        <title>AJAX Example</title>
        <script language="javascript">
            var XMLHttpRequestObject = false;

            if (window.XMLHttpRequest) {
                XMLHttpRequestObject = new XMLHttpRequest();
            } else if (window.ActiveXObject) {
                XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
            }

            function getData(dataSource, divID) {
                if (XMLHttpRequestObject) {
                    var obj = document.getElementById(divID);
                    XMLHttpRequestObject.open("GET", dataSource);

                    XMLHttpRequestObject.onreadystatechange = function() {
                        if (XMLHttpRequestObject.readystate == 4 && XMLHttpRequestObject.status == 200) {
                            obj.innerHTML = XMLHttpRequestObject.responseText;
                        }
                    }                   
                    XMLHttpRequestObject.send(null);
                }
            }        
        </script>
    </head>
    <body>
        <H1>This is an AJAX Example</H1>

        <form>
            <input type="button" value="Fetch the Message" onclick="getData('data.txt', 'targetDiv')">
        </form>
        <div id="targetDiv">
            <p>The fetched message is supposed to appear here...</p>
        </div>
    </body>
</html>

And is the contents of data.txt (saved in the same directory as ajax.html):

<p>This is some text in a file that I am using to be</p> 
<p>queried with an ajax process to display dynamically.</p>

The problem is that nothing happens when I press the button on the page. I have tried to step through the Javascript using Chrome’s developer tools and I see a DOMException:
enter image description here.

Can someone please point out if there is an issue with this javascript, or point me in the right direction to deal with the DOMException that I am seeing?

  • 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-27T07:56:08+00:00Added an answer on May 27, 2026 at 7:56 am

    using the answer found here I read that my readystate should really be readyState. Changing that fixed my problem.

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

Sidebar

Related Questions

I'm using Hibernate 3.3.1 and am following along in modelling this sample table structure
I have an HTML along the following lines: <div class=hiddenClass> // this implies display:none
I'm using the following jQuery plugins (along with the jQuery plugin): <script type=text/javascript src=scripts/jquery.scrollTo-min.js></script>
I'm following along a tutorial (Ruby) that uses a regex to remove all html
I've been following along with this excellent asio tutorial , but have got confused
Help! I've no idea what's going wrong here, I'm following along a tutorial video
So I'm following along with this tutorial , and I'm stuck. In Eclipse, I'm
I am starting to learn Qt4 and Python, following along some tutorial i found
I am just following along the spring tutorial ( http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html ) I downloaded this
I am a python/django newbie following along this tutorial on dotcloud . I git

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.