topical media & game development

talk show tell print

#javascript-code-13-html.htm / htm



  <html>
  <head>
      <title>HTML Sports Scores Loaded via AJAX</title>
      <!—Load in our generic AJAX function -->
      <script src="ajax.js"></script>
      <script>
          // Wait for the document to be fully loaded
          window.onload = function(){
              // Then load the RSS feed using AJAX
              ajax({
                  // The URL of the HTML sports scores
                  url: "scores.html",
  
                  // It's an HTML document
                  type: "html",
  
                  // This function will be executed whenever the request is complete
                  onSuccess: function( html ) {
                      // We're going to be inserting into the div that has an id of 'scores'
                      var scores = document.getElementById("scores");
  
                      // Inject the new HTML into the document
                      scores.innerHTML = html;
                  }
              });
          };
      </script>
  </head>
  <body>
      <h1> HTML Sports Scores Loaded via AJAX </h1>
       <!—This is where the Sports Scores to be inserted -->
      <div id="scores"></div>
  </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.