Jump to content

Recommended Posts

So I am following the w3schools AJAX toutorial to learn AJAX and I've got something wrong somewhere but I can't find it. The alert is my telltale, it won't fire unless I comment out the rest of the the function contents. Did I misread, mistype, or miscognate?

<!doctype html>
<html>
  <head>
    <script type = "text/javascript">
      function clicked(){
        alert("You clicked!");
        var pidgin = new XMLHttpRequest();
        pidgin.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
            document.getElementById("test").innerHTML = this.responseText;
          }
        };
        pidgin.open("GET", "test.txt", true);
        pidgin.send();
      }
    </script>
  </head>
  <body>
  <div id="test"></div>
  <a href="#" onclick="clicked();">click me</a>
  </body>
</html>

Share this post


Link to post
Share on other sites
Posted (edited)

Error

Edited by Karaethon
Error

Share this post


Link to post
Share on other sites

Ahh, there's a jQuery Ajax ability... jQuery does my heavy lifting for me... Shifting gears.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.