1 / 8

Using Ajax

Using Ajax. Asynchronous JavaScript and XML. An example of AJAX. What Is Ajax?. beginnings of Ajax as used today started with the release of Internet Explorer 5 in 1999 XMLHttpRequest is the way to go, and there have been numerous frameworks written to simplify its use.

pier
Download Presentation

Using Ajax

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Ajax Asynchronous JavaScript and XML

  2. An example of AJAX

  3. What Is Ajax? • beginnings of Ajax as used today started with the release of Internet Explorer 5 in 1999 • XMLHttpRequest is the way to go, and there have been numerous frameworks written to simplify its use

  4. Using XMLHttpRequest • IE 5: request = new ActiveXObject("Microsoft.XMLHTTP") • IE 6+: request = new ActiveXObject("Msxml2.XMLHTTP") • All others: request = new XMLHttpRequest() • Example 18-1. A cross-browser Ajax function • Table 18-1. An XMLHttpRequest object’s properties

  5. Your First Ajax Program • Type in and save the code in Example 18-2 as urlpost.html • PHP half of the equation, which you can see in Example 18-3.

  6. Using GET Instead of POST • Example 18-4 shows how you would achieve the same result as with Example 18-2, but using an Ajax GET request instead of POST. • To accompany this new document, it is necessary to modify the PHP program to respond to a GET request, as in Example 18-5, urlget.php

  7. Sending XML Requests • modify the previous example document and PHP program to fetch some XML data. To do this, take a look at the PHP program first, xmlget.php, shown in Example 18-6. • to the HTML document, xmlget.html, shown in Example 18-7.

  8. About XMLAn XML document • XML document will generally take the form of the RSS feed shown in Example 18-8. However, the beauty of XML is that this type of structure can be stored internally in a DOM tree (see Figure 18-3) to make it quickly searchable

More Related