Head Rush Ajax


book cover
Head Rush Ajax
By Brett McLaughlin
...............................................
Publisher: O'Reilly
Pub Date: March 2006
Print ISBN-10: 0-596-10225-9
Print ISBN-13: 978-0-59-610225-8
Pages: 446
 

Table of Contents  | Index
overview


Sick of creating web sites that reload every time a user moves the mouse? Tired of servers that wait around to respond to users' requests for movie tickets? It sounds like you need a little (or maybe a lot of) Ajax in your life. Asynchronous programming lets you turn your own websites into smooth, slick, responsive applications that make your users feel like they're back on the information superhighway, not stuck on a dial-up backroad.



But who wants to take on next-generation web programming with the last generation's instruction book? You need a learning experience that's as compelling and cutting-edge as the sites you want to design. That's where we come in. With Head Rush Ajax, in no time you'll be writing JavaScript code that fires off asynchronous requests to web servers...and having fun doing it. By the time you've taken your dynamic HTML, XML, JSON,
and DOM skills up a few notches, you'll have solved tons of puzzles, figured out how well snowboards sell in Vail, and even watched a boxing match. Sound interesting? Then what are you waiting for? Pick up Head Rush Ajax and learn Ajax and asynchronous programming the right way--the way that sticks.



If you've ever read a Head First book, you know what to expect: a visually rich format designed for the way your brain works. Head Rush ramps up the intensity with an even faster look and feel. Have your first working app before you finish Chapter 1, meet up with the nefarious PROJECT: CHAOS stealth team, and even settle the question of the Top 5 Blues CDs of all time. Leave boring, clunky websites behind with 8-tracks and hot pants--and get going with next-generation web programming.



"If you thought Ajax was rocket science, this book is for you. Head Rush Ajax puts dynamic, compelling experiences within reach for every web developer."
-- Jesse James Garrett, Adaptive Path



"A 'technology-meets-reality' book for web pioneers on the cutting edge."
-- Valentin Crettaz, CTO, Condris Technologies



book cover
Head Rush Ajax
By Brett McLaughlin
...............................................
Publisher: O'Reilly
Pub Date: March 2006
Print ISBN-10: 0-596-10225-9
Print ISBN-13: 978-0-59-610225-8
Pages: 446
 

Table of Contents  | Index

   Copyright
   Dedication
   Preface
   Meet your author
   Intro
      Chapter 1.  Web Applications for a New Generation: Using Ajax
      Section 1.1.  The Web, Reloaded
      Section 1.2.  Welcome to the new millenium!
      Section 1.3.  "Reloads? We don't need no stinking reloads."
      Section 1.4.  Ajax to the rescue
      Section 1.5.  Reworking the Boards 'R' Us report
      Section 1.6.  HTML Refresher
      Section 1.7.  What the server used to do...
      Section 1.8.  Frequently Asked Questions?
      Section 1.9.  Make sure the server is finished
      Section 1.10.  Checking for the right ready state
      Section 1.11.  Just Do It
      Section 1.12.  Showing Katie some Ajax magic
      Section 1.13.  You did it! You took a boring sales report, and turned it into a dynamic Ajax application!
      Section 1.14.  Reviewing the highlight reel
      Section 1.15.  Exercise Solutions
      Chapter 2.  Making Ajax Requests: Speaking the Language
      Section 2.1.  Break Neck Pizza Delivery
      Section 2.2.  Solving the pizza delivery problem
      Section 2.3.  Break Neck Pizza, Ajax-style
      Section 2.4.  Diagramming the Break Neck app
      Section 2.5.  Be the Architect
      Section 2.6.  Step 1: Get the customer's phone number
      Section 2.7.  HTML 101: accepting user input
      Section 2.8.  Event handlers connect HTML to JavaScript
      Section 2.9.  Event handler roundup
      Section 2.10.  Frequently Asked Questions?
      Section 2.11.  On to the JavaScript
      Section 2.12.  Use the DOM to get the phone number
      Section 2.13.  Connecting the DOM dots
      Section 2.14.  Step 2: Request the customer's address
      Section 2.15.  getCustomerInfo() at a glance
      Section 2.16.  Creating a request object
      Section 2.17.  Plans change
      Section 2.18.  Supporting multiple browsers
      Section 2.19.  Just Do It
      Section 2.20.  Back to getCustomerInfo()
      Section 2.21.  Talking to the server-side guys
      Section 2.22.  Break Neck's PHP script
      Section 2.23.  Request URLs deliver data to the server
      Section 2.24.  Giving instructions to the browser
      Section 2.25.  Frequently Asked Questions?
      Section 2.26.  Send the request to the server
      Section 2.27.  Podcasting Studio
      Section 2.28.  Step 3: Retrieve the customer's address
      Section 2.29.  Under the Microscope: HTTP Ready States
      Section 2.30.  Checking the ready state
      Section 2.31.  Frequently Asked Questions?
      Section 2.32.  What is the browser doing?
      Section 2.33.  Get the server's response from the request object
      Section 2.34.  Step 4: Update the order form
      Section 2.35.  Finishing off the callback function
      Section 2.36.  Frequently Asked Questions?
      Section 2.37.  Test driving the Break Neck app
      Section 2.38.  When browsers cache request URLs...
      Section 2.39.  Now the request URL changes...
      Section 2.40.  Just Do It
      Section 2.41.  Frequently Asked Questions?
      Section 2.42.  Step 5: Place the customer's pizza order
      Section 2.43.  Back to Break Neck's order form
      Section 2.44.  The final test drive
      Section 2.45.  EXERCISE SOLUTION
      Chapter 2a.  TOP SECRET: Eyes Only Duplication strictly prohibited
      Section 2a.1.  Problems at Break Neck...
      Section 2a.2.  Checking the request's status
      Section 2a.3.  Servers return a ready state and a status code
      Section 2a.4.  Back to Break Neck...
      Chapter 3.  She Blinded Me with Asynchronous
      Section 3.1.  What does asynchronous really mean?
      Section 3.2.  Break Neck Pizza is an asynchronous app
      Section 3.3.  But it was probably too fast for you to notice...
      Section 3.4.  What does asynchronous get you?
      Section 3.5.  Building an Ajax-powered coffee maker
      Section 3.6.  Three ingredients for asynchronous coffee
      Section 3.7.  Connecting the parts of the coffee maker
      Section 3.8.  How is the coffee maker going to work?
      Section 3.9.  The back-and-forth of Ajax development
      Section 3.10.  The coffee maker HTML
      Section 3.11.  Here's what we did...
      Section 3.12.  Sending a request for coffee
      Section 3.13.  Writing JavaScript to send the request
      Section 3.14.  Getting the beverage and size of the order
      Section 3.15.  Getting the value of a radio group
      Section 3.16.  What JavaScript do we still need to write?
      Section 3.17.  Getting and setting the text content in a <div>
      Section 3.18.  Checking a coffee maker's status
      Section 3.19.  Setting the text in a <div>
      Section 3.20.  Test drive
      Section 3.21.  What do we do with the server's response?
      Section 3.22.  Writing the callback function
      Section 3.23.  Interpreting the server's response
      Section 3.24.  Introducing the JavaScript substring() function
      Section 3.25.  substring() practice
      Section 3.26.  Finishing up serveDrink()
      Section 3.27.  Frequently Asked Questions?
      Section 3.28.  The final test drive (right?)
      Section 3.29.  A closer look at the request object
      Section 3.30.  We need two request objects!
      Section 3.31.  Creating two request objects
      Section 3.32.  Using two request objects
      Section 3.33.  Updating orderCoffee()
      Section 3.34.  Frequently Asked Questions?
      Section 3.35.  Welcome to the world of asynchrony!
      Section 3.36.  A synchronous test drive
      Section 3.37.  Change that baby back to asynchronous!
      Chapter 4.  The Document Object Model:Web Page Forestry
      Section 4.1.  Need a dynamic application?
      Section 4.2.  Meet the DOM (again)
      Section 4.3.  Under the Microscope: The document object
      Section 4.4.  Using the DOM without Ajax
      Section 4.5.  Here's the HTML that you give to the browser...
      Section 4.6.  ...and here's how the browser sees the HTML
      Section 4.7.  Frequently Asked Questions?
      Section 4.8.  Frequently Asked Questions?
      Section 4.9.  Back to the forest
      Section 4.10.  Browsers see the world upside down
      Section 4.11.  A new type of tree: the DOM tree
      Section 4.12.  Podcasting Studio
      Section 4.13.  Moving around in a DOM tree
      Section 4.14.  Frequently Asked Questions?
      Section 4.15.  Some browsers don't recognize Node
      Section 4.16.  Frequently Asked Questions?
      Section 4.17.  Exercise Solutions
      Chapter 4.5.  A Second Helping
      Section 4a.1.  Everyone's a critic
      Section 4a.2.  Checking out top5.html
      Section 4a.3.  What's the game plan?
      Section 4a.4.  The big picture
      Section 4a.5.  Setting up the CD covers
      Section 4a.6.  Adding event handlers
      Section 4a.7.  Running addOnClickHandlers()
      Section 4a.8.  Adding a CD to the top 5
      Section 4a.9.  After addToTop5() runs...
      Section 4a.10.  Pay attention to "this "
      Section 4a.11.  Finding the "top5" <div>
      Section 4a.12.  Adding children to an element
      Section 4a.13.  Back to event handlers
      Section 4a.14.  Testing addToTop5()
      Section 4a.15.  Adding the ranking number
      Section 4a.16.  What's left to do?
      Section 4a.17.  Completing addToTop5()
      Section 4a.18.  Testing the CD rankings (again)
      Section 4a.19.  A final test drive
      Chapter 5.  POST Requests: Saying More with POST
      Section 5.1.  Repeat business rocks
      Section 5.2.  Submitting a form with Ajax
      Section 5.3.  1. Update the Break Neck HTML
      Section 5.4.  2. Send the order to the server
      Section 5.5.  3. Update placeOrder.php
      Section 5.6.  PHP ...at a glance
      Section 5.7.  4. Write the callback function
      Section 5.8.  The DOM is connected to what a customer sees
      Section 5.9.  Test driving Break Neck
      Section 5.10.  Just Do It Solution
      Section 5.11.  The PHP code creates a new response header:
      Section 5.12.  The server talks back
      Section 5.13.  Break Neck error handling
      Section 5.14.  GET requests versus POST requests
      Section 5.15.  Web servers unencode POST data
      Section 5.16.  Send more data with a POST request
      Section 5.17.  Trying out POST requests
      Section 5.18.  Why didn't the POST request work?
      Section 5.19.  The mysterious POST data
      Section 5.20.  Setting the Content Type
      Section 5.21.  Another test drive
      Section 5.22.  EXERCISE SOLUTIONS
      Chapter 5a. 
      Section 5a.1.  Injecting mischief into Break Neck
      Section 5a.2.  Break Neck Pizza online
      Section 5a.3.  Welcome to SQL injection
      Section 5a.4.  Protecting against SQL injection in your JavaScript
      Section 5a.5.  What's wrong with the PHP script?
      Section 5a.6.  SQL injection attacks without the web form
      Section 5a.7.  Protecting against SQL injection in your PHP scripts
      Section 5a.8.  Your customer database is secure!
      Chapter 6.  More Than Words Can Say
      Section 6.1.  XML: just what the doctor ordered
      Section 6.2.  Remember Katie?
      Section 6.3.  The problem with Boards 'R' Us
      Section 6.4.  Filling that XML prescription
      Section 6.5.  more Frequently asked questions
      Section 6.6.  Trees, trees, everywhere I look
      Section 6.7.  Using responseXML in your code
      Section 6.8.  Just Do It
      Section 6.9.  Trying things out
      Chapter 7.  A Fight to the Finish
      Section 7.1.  A review of request and response formats
      Section 7.2.  Should you use XML or JSON?
      Section 7.3.  The heavyweight champion: XML
      Section 7.4.  The young upstart: JSON
      Section 7.5.  Frequently asked questions?
      Section 7.6.  Just Do It
      Section 7.7.  So which is the better data format?
      Section 7.8.  Which data format should you use?: The choice......is yours!
      Section 7.9.  Just Do It Solutions
      Appendix A.  A Few Special Bonus Gifts
      Section A.1.  #1: Ajax toolkits
      Section A.2.  #2: script.aculo.us and other UI libraries
      Section A.3.  #3: Inspecting the DOM
      Section A.4.  Inspecting the DOM in Internet Explorer
      Section A.5.  Inspecting the DOM in Safari
      Section A.6.  #4: Using JSON libraries in your PHP scripts
      Section A.7.  #5: Using eval() with JSON
      Section A.8.  Use a JSON parser
      Appendix B.  "All I Want Is the Code."
      Section B.1.  ajax.js
      Section B.2.  Using ajax.js
      Section B.3.  Using text-utils.js
   Preface
   Index