You are previewing Ajax Patterns and Best Practices.
O'Reilly logo
Ajax Patterns and Best Practices

Book Description

Ajax is taking us into the next generation of web applications. Ajax has broken the client-server barrier by decoupling the client from the server, but an Ajax application still needs a server to extract content from. The most effective use of Ajax and the server requires an understanding of REST, an architectural style used to define Web services.

Ajax Patterns and Best Practices explores dynamic web applications that combine Ajax and REST as a single solution. A major advantage of REST is that like Ajax, it can be used with today's existing technologies.

This is an ideal book whether or not you have already created an Ajax application. Because the book outlines various patterns and best practices, you can quickly check and verify that you're building an efficient Ajax application.

Table of Contents

  1. Copyright
  2. About the Author
  3. About the Technical Reviewer
  4. Acknowledgments
  5. Introduction
    1. What's My Vision of Ajax?
    2. Book and Pattern Road Map
  6. 1. Introduction to Ajax
    1. 1.1. Pictures Are Worth a Thousand Words
    2. 1.2. Another Ajax Example
    3. 1.3. Ajax Architecture Basics
      1. 1.3.1. It's About the Data
      2. 1.3.2. It's About the Navigation
    4. 1.4. Comparing Ajax to Other Application Types
      1. 1.4.1. Rich-Client Local Installation
      2. 1.4.2. Rich-Client Web Services
      3. 1.4.3. Plain-Vanilla Web Application
    5. 1.5. Some Final Thoughts
  7. 2. The Nuts and Bolts of Ajax
    1. 2.1. Ajax for the Impatient
      1. 2.1.1. Understanding REST Theory
      2. 2.1.2. Implementing the REST Data
      3. 2.1.3. Implementing the Ajax Application
      4. 2.1.4. Putting Together Ajax and REST
      5. 2.1.5. Understanding the Ramifications of Ajax and REST
      6. 2.1.6. XMLHttpRequest Details
      7. 2.1.7. Using the Factory Pattern
      8. 2.1.8. Defining an XMLHttpRequest Factory
      9. 2.1.9. Rewriting the Ajax Application to Use a Factory
    2. 2.2. Making Asynchronous Requests
    3. 2.3. Making Practical Use of XMLHttpRequest
      1. 2.3.1. Implementing an Asynchronous Calling Mechanism
      2. 2.3.2. Calling Domains Other Than the Serving Domain
    4. 2.4. Some Final Thoughts
  8. 3. Content Chunking Pattern
    1. 3.1. Intent
    2. 3.2. Motivation
    3. 3.3. Applicability
    4. 3.4. Associated Patterns
    5. 3.5. Architecture
      1. 3.5.1. Implementing Order in a Web Application
      2. 3.5.2. Defining the Content Within a Content Chunk
    6. 3.6. Implementation
      1. 3.6.1. Implementing the HTML Framework Page
      2. 3.6.2. Injecting Content by Using Dynamic HTML
      3. 3.6.3. Understanding the Special Nature of innerHTML
      4. 3.6.4. Binary, URL, and Image Chunking
      5. 3.6.5. JavaScript Chunking
    7. 3.7. Pattern Highlights
  9. 4. Cache Controller Pattern
    1. 4.1. Intent
    2. 4.2. Motivation
    3. 4.3. Applicability
    4. 4.4. Associated Patterns
    5. 4.5. Architecture
      1. 4.5.1. HTML and HTTP Cache Directives
      2. 4.5.2. HTTP Expiration Caching Is a Bad Idea (Generally)
      3. 4.5.3. A Better Approach: Using HTTP Validation
      4. 4.5.4. Some Findings Regarding Server-Side Caching
      5. 4.5.5. Defining Static HTTP Validation
      6. 4.5.6. Defining Dynamic HTTP Validation
    6. 4.6. Implementation
      1. 4.6.1. Implementing the Passive Cache
      2. 4.6.2. Implementing the Server Side of the HTTP Validator
    7. 4.7. Pattern Highlights
  10. 5. Permutations Pattern
    1. 5.1. Intent
    2. 5.2. Motivation
    3. 5.3. Applicability
    4. 5.4. Associated Patterns
    5. 5.5. Architecture
      1. 5.5.1. Understanding Why the Resource Is Separated from the Representation
      2. 5.5.2. Using Cookies and HTTP Authentication to Authorize Access Only
      3. 5.5.3. Using Cookies
      4. 5.5.4. An Example Book Application
    6. 5.6. Implementation
      1. 5.6.1. Rewriting URLs
      2. 5.6.2. An Example Shopping Cart Application
    7. 5.7. Pattern Highlights
  11. 6. Decoupled Navigation Pattern
    1. 6.1. Intent
    2. 6.2. Motivation
    3. 6.3. Applicability
    4. 6.4. Associated Patterns
    5. 6.5. Architecture
    6. 6.6. Implementation
      1. 6.6.1. Implementing the Action Functionality
      2. 6.6.2. Defining and Implementing the Common Data Functionality
      3. 6.6.3. Implementing the Presentation Functionality
      4. 6.6.4. Using HTML Components
    7. 6.7. Pattern Highlights
  12. 7. Representation Morphing Pattern
    1. 7.1. Intent
    2. 7.2. Motivation
    3. 7.3. Applicability
    4. 7.4. Associated Patterns
    5. 7.5. Architecture
      1. 7.5.1. Basic Theory
      2. 7.5.2. Why the Pattern Is Not an HTML Component
      3. 7.5.3. Defining Blocks of State
    6. 7.6. Implementation
      1. 7.6.1. Implementing the Framework
      2. 7.6.2. Implementing the Representation Reference Points
      3. 7.6.3. The Details of a JavaScript Representation Reference Point
      4. 7.6.4. The Details of an XSLT Representation Reference Point
      5. 7.6.5. Some Implementation Details
    7. 7.7. Pattern Highlights
  13. 8. Persistent Communications Pattern
    1. 8.1. Intent
    2. 8.2. Motivation
    3. 8.3. Applicability
    4. 8.4. Associated Patterns
    5. 8.5. Architecture
      1. 8.5.1. Why the Internet Is "Broken"
      2. 8.5.2. Implementing a Polling Solution
    6. 8.6. Implementation
      1. 8.6.1. Example: A Global Status Resource
      2. 8.6.2. Implementing the HTML Page
      3. 8.6.3. Implementing the ClientCommunicator
      4. 8.6.4. Implementing the ServerCommunicator
      5. 8.6.5. Calling the ServerCommunicator Intelligently
      6. 8.6.6. Implementing the Server-Side Monitoring Process
    7. 8.7. Example: Presence Detection
      1. 8.7.1. Authenticating the User
      2. 8.7.2. Updating the ServerCommunicator
    8. 8.8. Example: Server Push
      1. 8.8.1. Some Thoughts on Specifying URLs
      2. 8.8.2. Using a Hard-Coded URL
      3. 8.8.3. Specifying a URL by Using User Identification
      4. 8.8.4. Specifying a URL by Using HTTP Redirection
      5. 8.8.5. Completing the ServerCommunicator
    9. 8.9. Version Numbers and Updates
    10. 8.10. Performance Considerations
    11. 8.11. Pattern Highlights
  14. 9. State Navigation Pattern
    1. 9.1. Intent
    2. 9.2. Motivation
    3. 9.3. Applicability
    4. 9.4. Associated Patterns
    5. 9.5. Architecture
      1. 9.5.1. Moving Toward an Ideal Solution from the User's Perspective
      2. 9.5.2. Extending the Solution for a Web Application
      3. 9.5.3. Managing State at the Protocol Level
    6. 9.6. Implementation
      1. 9.6.1. Processing the Requests on the Client
      2. 9.6.2. Processing the Requests on the Server
    7. 9.7. Pattern Highlights
  15. 10. Infinite Data Pattern
    1. 10.1. Intent
    2. 10.2. Motivation
    3. 10.3. Applicability
    4. 10.4. Associated Patterns
    5. 10.5. Architecture
    6. 10.6. Implementation
      1. 10.6.1. Implementing the HTML Client
      2. 10.6.2. Implementing the Task Manager
    7. 10.7. Pattern Highlights
  16. 11. REST-Based Model View Controller Pattern
    1. 11.1. Intent
    2. 11.2. Motivation
    3. 11.3. Applicability
    4. 11.4. Associated Patterns
    5. 11.5. Architecture
      1. 11.5.1. The Big Picture
      2. 11.5.2. Defining an Appropriate Resource
      3. 11.5.3. Defining the Calling Interface
      4. 11.5.4. Defining the Data Format Foundation and the Extras
    6. 11.6. Implementation
      1. 11.6.1. Implementing a Search
      2. 11.6.2. Creating a Search Engine Client Infrastructure
      3. 11.6.3. Putting All of the Pieces Together
    7. 11.7. Pattern Highlights