index | next

JavaScript Libraries for Ajax

Ajax requests are often similar and repetitive.

JavaScript libraries exist to perform common operations and to guarantee that code will run on all major browsers.

For example, we can replace the previous showDateAndTime() function with the following:

      function showDateAndTime() {
          new Ajax.Updater("dateDIV",           // DIV to update
                           "dateAndTime.ajax",  // URL
                           { method: "get" });  // HTTP method
      }
This is a 94% reduction in code.

index | next