topical media & game development

talk show tell print

professional-web-03-YUIConnectionManager.htm / htm



  <?xml version="1.0" encoding="ISO-8859-1"?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <script src="yahoo.js" type="text/javascript"></script>
          <script src="connection.js" type="text/javascript"></script>
          <script type="text/javascript">
              var callback = {
                  success: function(o) {
                      var nodes = o.responseXML.documentElement.childNodes;
                      var membersList = document.getElementById("members");
                      for (var i = 0; i < nodes.length; i++) {
                          if (nodes[i].nodeType == 1) {
                              var name = nodes[i].childNodes[0].nodeValue;
                              var li = document.createElement("li");
                              li.appendChild(document.createTextNode(name))
                              membersList.appendChild(li);
                          }
                      }
                  }
              }
  
              function loadSimpsons() {
                  YAHOO.util.Connect.asyncRequest
                      ("GET", "simpsons.xml", callback, null);
              }
          </script>
      </head>
          <body>
          <p>
              <button onclick="loadSimpsons()">Load family</button>
          </p>
          <ul id="members">
          </ul>
      </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.