Chapter 1: AJAX and the Future of Web Applications 7
Delivering Functionality via the Web 8
Advantages of Web Applications 9
Building Websites Since 1990 10
HTTP and HTML 10
PHP and Other Server-Side Technologies 11
Java****** and Other Client-Side Technologies 12
Whats Been Missing? 13
Understanding AJAX 14
Building a Simple Application with AJAX and PHP 18
Time for Action—Quickstart AJAX 21
Summary 28
Chapter 2: Client-Side Techniques with Smarter Java****** 29
Java****** and the Document Object Model 30
Time for Action—Playing with Java****** and the DOM 32
Java****** Events and the DOM 33
Time for Action—Using Java****** Events and the DOM 35
Even More DOM 37
Time for Action—Even More DOM 37
Java******, DOM, and CSS 39
Time for Action—Working with CSS and Java****** 39
Using the XMLHttpRequest Object 42
Creating the XMLHttpRequest Object 43
Creating Better Objects for Internet Explorer 45
Initiating Server Requests Using XMLHttpRequest 46
Handling Server Response 49
Time for Action—Making Asynchronous Calls with XMLHttpRequest 50
Table of Contents
Working with XML Structures 55
Time for Action—Making Asynchronous Calls with XMLHttpRequest and XML 55
Handling More Errors and Throwing Exceptions 59
Creating XML Structures 63
Summary 64
Chapter 3: Server-Side Techniques with PHP and MySQL 65
PHP and DOM 65
Time for Action—Doing AJAX with PHP 66
Passing Parameters and Handling PHP Errors 71
Time for Action—Passing PHP Parameters and Error Handling 72
Connecting to Remote Servers and Java****** Security 79
Time for Action—Connecting to Remote Servers 81
Using a Proxy Server ****** 85
Time for Action—Using a Proxy Server ****** to Access Remote Servers 86
A Framework for Making Repetitive Asynchronous Requests 91
Time for Action—Implementing Repetitive Tasks 93
Working with MySQL 101
Creating Database Tables 101
Manipulating Data 104
Connecting to Your Database and Executing Queries 105
Time for Action—Working with PHP and MySQL 106
Wrapping Things Up and Laying Out the Structure 109
Time for Action—Building the Friendly Application 112
Summary 119
Chapter 4: AJAX Form Validation 121
Implementing AJAX Form Validation 122
Thread-Safe AJAX 125
Time for Action—AJAX Form Validation 126
Summary 144
Chapter 5: AJAX Chat 145
Introducing AJAX Chat 145
Implementing AJAX Chat 147
Time for Action—Ajax Chat 148
Summary 164 ii
Table of Contents
Chapter 6: AJAX Suggest and Autocomplete 165
Introducing AJAX Suggest and Autocomplete 165
Google Suggest 166
Implementing AJAX Suggest and Autocomplete 167
Time for Action—AJAX Suggest and Autocomplete 168
Summary 188
Chapter 7: AJAX Real-Time Charting with SVG 189
Implementing a Real-Time Chart with AJAX and SVG 190
Time for Action—Building the Real-Time SVG Chart 193
Summary 202
Chapter 8: AJAX Grid 203
Implementing the AJAX Grid Using Client-Side XSLT 204
Time for Action—AJAX Grid 205
Summary 221
Chapter 9: AJAX RSS Reader 223
Working with RSS 223
The RSS Document Structure 224
Google Reader 224
Implementing the AJAX RSS Reader 225
Time for Action—Building the RSS Reader Application 226
Summary 236
Chapter 10: AJAX Drag and Drop 237
Using Drag and Drop on the Web 237
Shopping Carts 237
Sortable Lists 238
Building the AJAX Drag-and-Drop Sortable List Application 238
Time for Action—Task Management Application with AJAX 241
Summary 253
Appendix A: Preparing Your Working Environment 255
Preparing Your Windows Playground 256
Installing Apache 256
Installing MySQL 258
Installing PHP 259 iii
Table of Contents
Preparing Your *nix Playground 261
Installing Apache 261
Installing MySQL 261
Installing PHP 262
Installing phpMyAdmin 263
Preparing the AJAX Database 264
Index 267