Scriptin' with JavaScript and Ajax
Table of Contents
- Introduction • xii
- Chapter 1 : JavaScript Comes of Age • 2
- Accessibility and Progressive Enhancement • 5
- Three Steps to Progressive Enhancement • 7
- 1. Make It Functional • 8
- 2. Make It Look Good • 17
- 3. Enhance the Experience with JavaScript and Ajax • 21
- Summary • 23
- Chapter 2 : JavaScript Basics • 24
- Running the Code Examples • 26
- Hello, JavaScript • 27
- Scripts, Statements, and Comments • 28
- Scripts • 28
- Statements • 28
- Comments • 29
- Data and Ways to Store It • 30
- Variables • 30
- Strings • 32
- Numbers • 34
- Booleans • 34
- Arrays • 34
- Code that Acts on Data • 38
- Operators • 38
- Loops and Iterating Over Data • 46
- Functions • 50
- Summary • 55
- Running the Code Examples • 26
- Chapter 3 : Objects and the DOM • 56
- Objects • 58
- Predefined JavaScript Objects • 59
- User-created Objects • 60
- Objects and Instances • 63
- DOMinating the Document • 68
- Getting Around the DOM • 68
- Get, Set…DOM! • 70
- Modifying Element Styles • 75
- Zebra Tables • 78
- Refactoring the Code • 85
- Summary • 87
- Objects • 58
- Techniques to Handle Events • 90
- JavaScript Pseudo Protocol • 90
- Inline Event Handler • 91
- Handler as Object Property • 93
- Event Listeners • 94
- The First Event: load • 97
- Adding Event Listeners on Page Load • 99
- The Event Object • 103
- The Event Object’s Type Property • 104
- The Event Object in Microsoft Browsers • 105
- The Secret Life of Events • 111
- Capturing and Bubbling • 112
- Event Delegation • 112
- Striped Table with Rollovers • 113
- Using an Element as a Debugging Tool • 113
- Mouse events • 114
- Event Delegation • 114
- Determining the Target Element • 116
- Traversing the DOM • 118
- Adding the Highlight • 120
- The Up and Down Life of Keys • 122
- Text Fields with Character Limits • 123
- Setting Up the Message Display • 124
- Monitoring the Character Count • 127
- The Finished Code • 130
- Summary • 131
- Understanding Ajax • 134
- Ajax by the Letters • 134
- Communication with the Server • 136
- The XMLHttpRequest Object • 138
- How to Use the XMLHttpRequest (XHR) Object • 139
- Using the Ajax Function • 144
- Using an Object Literal to Maintain State Through an Ajax Call • 146
- Ajax and Data Formats • 149
- Creating a Simple Catalog • 149
- Using PHP Templates • 150
- An Ajax-ready Page • 155
- Adding Ajax Functionality to the Catalog • 156
- An Accessible Catalog • 161
- Working with JSON • 162
- The Guitar Catalog Using JSON • 164
- Using XML • 167
- Using Sajax-the Simple Ajax Framework • 173
- Summary • 177
- About Frameworks • 180
- Advantages of Frameworks • 180
- Considerations When Using a Framework • 181
- Namespacing • 182
- Pseudo-global Variables • 184
- Ajax Implementation in Four Frameworks • 186
- jQuery Namespace • 186
- Prototype • 188
- Yahoo! User Interface (YUI) • 189
- Adobe Spry • 190
- RIA Components • 191
- Accordion with jQuery and Spry • 191
- Highlight with Prototype and Spry • 195
- Drag-and-drop with Prototype and jQuery • 197
- Tabs with jQuery and Spry • 200
- Summary • 203
- About the Projects • 206
- An Image Carousel • 207
- A Location Finder with AutoComplete • 208
- Building the Author Carousel • 209
- Styling the Carousel • 211
- Managing the Scrollbar • 214
- The PHP backend • 215
- Layering on the JavaScript • 222
- Implementing the Carousel Interactions • 224
- Implementing the Overlay • 228
- Parsing the JSON with JavaScript • 230
- AutoComplete and Maps with the Yahoo! API • 233
- The Location Data • 234
- The Project Template—index.php • 234
- The Search Form Script—searchform.php • 239
- Implementing Search Without JavaScript—searchresults.php • 248
- Summary • 250