Ajax with PHP 5

Book description

"Ajax with PHP 5" is a detailed overview of how to use PHP technologies to create interactive, fault-tolerant, and responsive web applications.

This Short Cut first concentrates on the fundamentals of Ajax. Then it covers serving (or providing) content formatted in both XML and JSON.

Finally, we completely immerse ourselves in the Ajax world and write two PHP applications that use each markup language on both the client and server.

We encourage you to use the classes and examples given to produce your own rich Web 2.0-style applications.

Table of contents

  1. Ajax with PHP 5
    1. PHP with Ajax
    2. The "Hello World" of Ajax and PHP
      1. The PHP File
      2. The JavaScript
      3. The XMLHTTPRequestObject
      4. Ready State and Status
      5. Unobtrusive JavaScript
      6. Quick Testing Tips
      7. Review
    3. The Example Given
      1. The CSV File
      2. Loading and Searching the CSV File
    4. Serving XML
      1. Designing an XML File
      2. The PHP Scripts
        1. The XMLNode Class
        2. The XMLPrinter Class
        3. The Main PHP Script
          1. If count($_GET) == 0 (the else block)
          2. If count($_GET) > 0
      3. The JavaScript
      4. Parsing XML with JavaScript
      5. Handling Mal-formatted XML
    5. Serving JSON
      1. Designing the JSON File
        1. Arrays in JSON
        2. Objects in JSON
      2. The PHP Scripts
        1. Printing JSON the easy way with the JSON module
        2. Printing JSON the harder way with the JSONPrinter Class
        3. The Main PHP Script
      3. Parsing JSON Data in JavaScript
        1. Handling mal-formatted JSON
        2. An alternative way to evaluate JSON
    6. Consuming XML
      1. Designing the XML Request
      2. The PHP File
        1. Parsing XML the easy way with SimpleXML
        2. Parsing XML the harder way with XMLParser class
      3. The Search Form
        1. Adapting the form to use SimpleXML
      4. Making the Search Form Interactive
      5. Generating XML Requests with JavaScript
      6. Putting All the JavaScript Together
    7. Consuming JSON
      1. Designing the JSON Request and Response
      2. Generating the JSON Query with JavaScript
      3. The JavaScript File
      4. The PHP File
      5. Review
    8. Some Closing Notes
      1. Additional Resources
      2. A Brief Word on Toolkits and Frameworks
    9. Appendix: PHP 4 versus 5
      1. Type Hinting
      2. Exception Handling
      3. __toString()
      4. Member Visibility
      5. Static Members
      6. JSON and XML Support
      7. Why Use PHP 5 at All?
    10. About the Author

Product information

  • Title: Ajax with PHP 5
  • Author(s):
  • Release date: May 2007
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596514037