Jump to content

AJAX ADuh?


Karaethon

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>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

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.