Book description
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 web sites 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 web sites 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
Publisher resources
Table of contents
- Head Rush Ajax
- Meet your author
- Table of Contents (summary)
- Table of Contents (the real thing)
- Intro
- Who is this book for?
- We know what you’re thinking.
- And we know what your brain is thinking.
- Metacognition: thinking about thinking
- Here’s what WE did:
- Here’s what YOU can do to bend your brain into submission
- Read Me
- Tech Reviewers
- And there’s a lot more...*
-
1 Using Ajax: Web Applications for a New Generation
- The Web, Reloaded
- Welcome to the new millenium!
- "Reloads? We don’t need no stinking reloads."
- Ajax to the rescue
- Reworking the Boards ‘R’ Us report
- The highlight reel: Chapter 1
- HTML Refresher
- Reviewing the Boards ‘R’ Us HTML
- Step 1: Creating a request object
- Step 2: Requesting updated sales
- Adding the getBoardsSold() function
- PHP...at a glance
- What the server used to do...
- What the server should do now
- The new script’s URL
- Initializing the connection
- Back to the HTML
- Running getBoardsSold() from the web form
- Adding an event handler
- Step 3: Coding updatePage()
- How we see web apps...
- Introducing the web browser
- The browser gives the server’s response to your JavaScript
- What should the browser do with the server’s response?
- Sending instructions to the browser
- Getting the server’s response
- Planning the updatePage() function
- Make sure the server is finished
- Checking for the right ready state
- Showing Katie some Ajax magic
- Wait! Stop the presses!
- What’s going on?
- 60 Second Review
-
2 Speaking the Language: Making Ajax Request
- Break Neck Pizza Delivery
- Solving the pizza delivery problem
- Break Neck Pizza, Ajax-style
- Diagramming the Break Neck app
- Be the Architect
- Step 1: Get the customer’s phone number
- HTML 101: accepting user input
- Event handlers connect HTML to JavaScript
- Event handler roundup
- On to the JavaScript
- Use the DOM to get the phone number
- Connecting the DOM dots
- Step 2: Request the customer’s address
- getCustomerInfo() at a glance
- Creating a request object
- Plans change
- Supporting multiple browsers
- Back to getCustomerInfo()
- Talking to the server-side guys
- Break Neck’s PHP script
- PHP...at a glance
- Request URLs deliver data to the server
- Giving instructions to the browser
- Send the request to the server
- Podcasting Studio
- Step 3: Retrieve the customer’s address
- HTTP Ready States
- Checking the ready state
- What is the browser doing?
- Get the server’s response from the request object
- Step 4: Update the order form
- Finishing off the callback function
- Test driving the Break Neck app
- Wait just a second...
- When browsers cache request URLs...
- Step 5: Place the customer’s pizza order
- Back to Break Neck’s order form
- The final test drive
- 60 Second Review (1/2)
- 60 Second Review (2/2)
- Problems at Break Neck...
- Checking the request’s status
- Servers return a ready state and a status code
- Back to Break Neck...
-
3 She Blinded Me with Asynchrony: Asynchronous Apps
- What does asynchronous really mean?
- Break Neck Pizza is an asynchronous app
- But it was probably too fast for you to notice...
- Building an Ajax-powered coffee maker
- Three ingredients for asynchronous coffee
- Connecting the parts of the coffee maker
- How is the coffee maker going to work?
- The back-and-forth of Ajax development
- The coffee maker HTML
- Here’s what we did...
- Sending a request for coffee
- Writing JavaScript to send the request
- Getting the beverage and size of the order
- Getting the value of a radio group
- What JavaScript do we still need to write?
- Getting and setting the text content in a
- Checking a coffee maker’s status
- Setting the text in a
- Test drive
- What do we do with the server’s response?
- Writing the callback function
- Interpreting the server’s response
- Introducing the JavaScript substring() function
- substring() practice
- Finishing up serveDrink()
- The final test drive (right?)
- So what happened to Jim’s coffee order?
- A closer look at the request object
- But what about Jim’s order?
- We need two request objects!
- Now you can keep up with both coffee orders.
- Creating two request objects
- Using two request objects
- Updating orderCoffee()
- Welcome to the world of asynchrony!
- Skeptical?
- A synchronous test drive
- Change that baby back to asynchronous!
- Two coffee makers, asynchrony, and one jittery, wired, happy office.
-
4 Web Page Forestry: the Document Object Model
- Need a dynamic application?
- Use the Document Object Model.
- Meet the DOM
- Under the Microscope: The document object
- Using the DOM without Ajax
- Better visit your local tree farm...
- Here’s the HTML that you give to the browser...
- ...and here’s how the browser sees the HTML
- How the browser sees your HTML (part 2)
- WRITE YOUR OWN Web Dictionary
- Back to the forest
- Browsers see the world upside down
- A new type of tree: the DOM tree
- Moving around in a DOM tree
- Some browsers don’t recognize Node
- The Great Chapter 4 Coding Challenge
-
4.5 A Second Helping: Developing DOM applications
- Everyone’s a critic
- Checking out top5.html
- What’s the game plan?
- The big picture
- Setting up the CD covers
- Use JavaScript to programmatically add event handlers to all elements.
- Adding event handlers
- Running addOnClickHandlers()
- Adding a CD to the top 5
- After addToTop5() runs...
- Pay attention to "this"
- Finding the "top5"
- Adding children to an element
- Back to event handlers
- Testing addToTop5()
- Adding the ranking number
- What’s left to do?
- Completing addToTop5()
- Testing the CD rankings (again)
- A final test drive
- The Great Chapter 4 Coding Challenge
-
5 Saying More with POST: POST Requests
- Repeat business rocks
- Submitting a form with Ajax
- 1. Update the Break Neck HTML
- 2. Send the order to the server
- 3. Update placeOrder.php
- PHP...at a glance
- When things go wrong
- 4. Write the callback function
- The DOM is connected to what a customer sees
- Test driving Break Neck
- Not so fast, Alex...
- The PHP code creates a new response header:
- The server talks back
- Break Neck error handling
- GET requests versus POST requests
- Web servers unencode POST data
- Send more data with a POST request
- Browsers don’t try and cache POST requests.
- Trying out POST requests
- Why didn’t the POST request work?
- The mysterious POST data
- Servers get information from the browser using request headers.
- Servers send information to the browser using response headers.
- Setting the Content Type
- Another test drive
- Break Neck Pizza online
- Welcome to SQL injection
- Protecting against SQL injection in your JavaScript
- What’s wrong with the PHP script?
- SQL injection attacks without the web form
- Protecting against SQL injection in your PHP scripts
- Your customer database is secure!
-
6 More Than Words Can Say: XML Requests & Responses
- servers don’t get to say much
- Speak Up!
- XML: just what the doctor ordered
- Remember Katie?
- The problem with Boards ‘R’ Us
- Filling that XML prescription
- PHP...at a glance
- Trees, trees, everywhere I look
- Using responseXML in your code
- Time to take a shortcut:
- Trying things out
- XML is a meta language: it defines other XML languages.
-
7 A Fight to the Finish: JSON versus XML
- A review of request and response formats
- Should you use XML or JSON?
- Fighting Words
- The heavyweight champion: XML
- You work with XML using the DOM.
- You use the DOM to work with XML
- The young upstart: JSON
- You work with JSON using “normal” JavaScript.
- You don’t need a special object model to work with JSON data
- JSON is JavaScript. (1/2)
- JSON is JavaScript. (2/2)
- So which is the better data format?
- We did say that JSON is JavaScript (1/2)
- We did say that JSON is JavaScript (2/2)
- JSON comes across as text (1/2)
- JSON comes across as text (2/2)
- You should use text data for your requests whenever possible. (1/2)
- You should use text data for your requests whenever possible. (2/2)
- So which is the better data format?
- Appendix 1: A Few Special Bonus Gifts: Extras
- Appendix 2: "All I Want Is the Code.": ajaz and DOM utilities
Product information
- Title: Head Rush Ajax
- Author(s):
- Release date: March 2006
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596102258
You might also like
article
Reinventing the Organization for GenAI and LLMs
Previous technology breakthroughs did not upend organizational structure, but generative AI and LLMs will. We now …
book
Head First Ajax
Ajax is no longer an experimental approach to website development, but the key to building browser-based …
article
Splitting Strings on Any of Multiple Delimiters
Build your knowledge of Python with this Shortcuts collection. Focusing on common problems involving text manipulation, …
article
Use Github Copilot for Prompt Engineering
Using GitHub Copilot can feel like magic. The tool automatically fills out entire blocks of code--but …