Ajax in Practice
Dave Crane, Jord Sonneveld and Bear Bibeault
with Ted Goddard, Chris Gray, Ram Venkataraman and Joe Walker
  • June 2007
  • ISBN 9781932394993
  • 536 pages

A 'second-generation' book that distills experience-based practices. Confident and balanced!

Ernest J. Friedman-Hill, Sandia National Laboratory, author of "Jess in Action"

Ajax gives web developers the potential to create rich user-centered Internet applications. But Ajax also adds a new level of complexity and sophistication to those applications. Ajax in Practice tackles Ajax head-on, providing countless hands-on techniques and tons of reusable code to address the specific issues developers face when building Ajax-driven solutions.

Table of Contents detailed table of contents

preface

acknowledgments

about this book

Part 1 Fundamentals of Ajax

1. Embracing Ajax

1.1. Ajax as a disruptive technology

1.1.1. Redefining the user’s workflow

1.1.2. Redefining web application architecture

1.2. Ajax in ten minutes

1.2.1. Introducing XMLHttpRequest

1.2.2. Instantiating XMLHttpRequest

1.2.3. Sending a request

1.2.4. Processing the response

1.2.5. Other XMLHttpRequest methods and properties

1.3. Making Ajax simple using frameworks

1.3.1. Making requests with Prototype’s Ajax.Request object

1.3.2. Simplifying Ajax responses

1.4. Summary

2. How to talk Ajax

2.1. Generating server-side JavaScript

2.1.1. Evaluating server-generated code

2.1.2. Utilizing good code-generation practices

2.2. Introducing JSON

2.2.1. Generating JSON on the server

2.2.2. Round-tripping data using JSON

2.3. Using XML and XSLT with Ajax

2.3.1. Parsing server-generated XML

2.3.2. Better XML handling with XSLT and XPath

2.4. Using Ajax with web services

2.5. Summary

3. Object-oriented JavaScript and Prototype

3.1. Object-oriented JavaScript

3.1.1. Object fundamentals

3.1.2. Functions are first class

3.1.3. Object constructors and methods

3.1.4. Writing a JavaScript class: a button

3.2. The Prototype library

3.2.1. Generally useful functions and extensions

3.2.2. Array extensions

3.2.3. The Hash class

3.2.4. Binding context objects to functions

3.2.5. Object-oriented Prototype

3.2.6. Rewriting the Button class with Prototype

3.3. Summary

4. Open source Ajax toolkits

4.1. The Dojo toolkit

4.1.1. Asynchronous requests with Dojo

4.1.2. Automatic form marshaling with Dojo

4.2. Prototype

4.2.1. Asynchronous requests with Prototype

4.2.2. Automatic updating with Prototype

4.2.3. Periodic updating with Prototype

4.3. jQuery

4.3.1. jQuery Basics

4.3.2. Asynchronous loading with jQuery

4.3.3. Fetching dynamic data with jQuery

4.4. DWR

4.4.1. Direct Web Remoting with DWR

4.5. Summary

Part 2 Ajax Best Practices

5. Handling events

5.1. Event-handling models

5.1.1. Basic event-handling registration

5.1.2. Advanced event handling

5.2. The Event object and event propagation

5.2.1. The Event object

5.2.2. Event propagation

5.3. Using Prototype for event handling

5.3.1. The Prototype Event API

5.4. Event types

5.4.1. Mouse events

5.4.2. Keyboard events

5.4.3. The change event

5.4.4. Page events

5.5. Putting events into practice

5.5.1. Validating text fields on the server

5.5.2. Posting form elements without a page submit

5.5.3. Submitting only changed elements

5.6. Summary

6. Form validation and submission

6.1. Client-side validation

6.1.1. Validating on the client side

6.1.2. Instant validation

6.1.3. Cross-field validation

6.2. Posting data

6.2.1. Anatomy of a POST

6.2.2. Posting data to a server

6.2.3. Posting form data to a server

6.2.4. Detecting form data changes

6.3. Summary

7. Content navigation

7.1. Principles of website navigation

7.1.1. Finding the needle in the haystack

7.1.2. Making a better needle-finder

7.1.3. Navigation and Ajax

7.2. Traditional web-based navigation

7.2.1. A simple navigation menu

7.2.2. DHTML menus

7.3. Borrowing navigational aids from the desktop app

7.3.1. The qooxdoo tab view

7.3.2. The qooxdoo toolbar and windows

7.3.3. The qooxdoo tree widget

7.4. Between the desktop and the Web

7.4.1. The OpenRico Accordion control

7.4.2. Building an HTML-friendly tree control

7.5. Summary

8. Handling back, refresh, and undo

8.1. Removing access to the browser’s navigation controls

8.1.1. Removing the toolbars

8.1.2. Capturing keyboard shortcuts

8.1.3. Disabling the right-click context menu

8.1.4. Preventing users from navigating history or refreshing

8.2. Working with a browser’s navigation controls

8.2.1. Using the JavaScript history object

8.2.2. Hashes as bookmarks

8.2.3. Introducing the Really Simple History (RSH) framework

8.2.4. Using RSH to maintain state at the client level

8.2.5. Using RSH to maintain state at the server level

8.3. Handling undo operations

8.3.1. When to provide undo capability

8.3.2. Implementing an undo stack

8.3.3. Extending the undo stack for more complex actions

8.4. Summary

9. Drag and drop

9.1. JavaScript drag-and-drop frameworks

9.2. Drag and drop for Ajax

9.2.1. Drag-and-drop Ajax shopping cart

9.2.2. Manipulating data in lists

9.2.3. The Ajax shopping cart using ICEfaces

9.3. Summary

10. Being user-friendly

10.1. Combating latency

10.1.1. Countering latency with feedback

10.1.2. Showing progress

10.1.3. Timing out Ajax requests

10.1.4. Dealing with multiple clicks

10.2. Preventing and detecting entry errors

10.2.1. Displaying proactive contextual help

10.2.2. Validating form entries

10.3. Maintaining focus and layering order

10.3.1. Maintaining focus order

10.3.2. Managing stacking order

10.4. Summary

11. State management and caching

11.1. Maintaining client state

11.2. Caching server data

11.2.1. Exchanging Java class data

11.2.2. Prefetching

11.3. Persisting client state

11.3.1. Storing and retrieving user state with JSON

11.3.2. Persisting JSON strings through AMASS

11.4. Summary

12. Open web APIs and Ajax

12.1. The Yahoo! Developer Network

12.1.1. Yahoo! Maps

12.1.2. The cross-server proxy

12.1.3. Yahoo! Maps Geocoding

12.1.4. Yahoo! Traffic

12.2. The Google Search API

12.3. Flickr photos

12.3.1. Flickr identification

12.3.2. Flickr photos and thumbnails

12.4. But wait! As they say, there’s more…​

12.4.1. Amazon services

12.4.2. eBay services

12.4.3. MapQuest

12.4.4. NOAA/National Weather Service

12.4.5. More, more, more…​

12.5. Summary

13. Mashing it up with Ajax

13.1. Introducing the Trip-o-matic application

13.1.1. Application purpose

13.1.2. Application overview and requirements

13.2. The Trip-o-matic data file

13.2.1. What format should we use?

13.2.2. The trip data format

13.2.3. Setting up Flickr photo sets

13.3. The TripomaticDigester class

13.3.1. The dependency check

13.3.2. The TripomaticDigester constructor

13.3.3. Digesting the trip data

13.3.4. Loading the points of interest

13.3.5. Collecting element text

13.4. The Tripomatic application class

13.4.1. The Tripomatic class and constructor

13.4.2. Creating the content elements

13.4.3. Filling in the trip data

13.4.4. Showing the map

13.4.5. Loading the thumbnails

13.4.6. Displaying the photos

13.5. The Trip-o-matic application page

13.5.1. The Trip-o-matic HTML document

13.5.2. Tripping along with style

13.6. Summary

index

About the book

After a brief overview of Ajax, this book takes the reader through dozens of working examples, presented in an easy-to-use cookbook format. Readers will learn how to implement drag-and-drop interfaces and discover how to create effective navigation strategies for their applications. Unlike a traditional cookbook, Ajax in Practice provides a thorough discussion of each technique presented and shows how the individual components can be connected to create powerful solutions. A fun "mash-up" chapter concludes the book. Throughout the book, the examples chosen are interesting, entertaining, and practical.

What's inside

  • Go beyond what Ajax is and learn how to put Ajax to work.
  • Master numerous techniques for user interface design and site navigation.
  • Work hands-on with professional-grade reusable Ajax code designed to solve real problems.

About the authors

Ajax in Practice boasts a team of authors including Dave Crane, leading Ajax authority and best-selling author of Manning's Ajax in Action, Bear Bibeault of JavaRanch, Jord Sonneveld of Google, Chris Gray of ClearNova, Ram Venkataraman of JBoss, Joe Walker, creator of DWR and Ted Goddard of IceFaces. Collectively, this group has thousands of hours putting Ajax to work in real-world products and solutions.


Buy
  • combo $44.99 pBook + PDF
  • eBook $35.99 PDF only

FREE domestic shipping on three or more pBooks

Any Ajax coder will benefit. [This book] will be useful for years to come.

Curt Christianson, Microsof MVP