Head rush Ajax 1st Edition by Brett Mclaughlin – Ebook PDF Instant Download/Delivery:0596102259 ,978-0596102258
Full download Head rush Ajax 1st Edition after payment

Product details:
ISBN 10: 0596102259
ISBN 13: 978-0596102258
Author: Brett Mclaughlin
Provides information on using Ajax in building Web applications.
Table of contents:
1 Using Ajax: Web Applications for a New Generation
The Web, Reloaded
The old way (think 1999)
Welcome to the new millenium!
No more waiting around…
…when you’re using Ajax apps
Ajax apps are asynchronous, too
“Reloads? We don’t need no stinking reloads.”
Ajax to the rescue
Use Ajax to fix the web report…
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
Sending the request to the right URL
PHP…at a glance
What the server used to do…
What the server should do now
The new script’s URL
Initializing the connection
Let’s break that down a bit…
Remember our checklist for getBoardsSold()?
Connecting to the web server
The server doesn’t need any data.
Reviewing what we’ve done
There are still some missing pieces
Back to the HTML
Running getBoardsSold() from the web form
Adding an event handler
Step 3: Coding updatePage()
Ajax is asynchronous JavaScript
Where does the response go?
How we see web apps…
Introducing the web browser
The browser just helps out
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
The browser helps out again
Planning the updatePage() function
Make sure the server is finished
Ready states are connected to your request object’s onreadystatechange property
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
What’s the deal?
Solving the pizza delivery problem
No kidding!
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
Plan first, code later
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
Don’t annoy the customer!
JavaScript doesn’t have to be in a function
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
Right—because updatePage() runs every time the ready state changes.
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…
Order matters in asynchronous apps
What’s going on in Windows?
When browsers cache request URLs…
Sometimes it takes a hack…
Good thinking!
Step 5: Place the customer’s pizza order
Back to Break Neck’s order form
The final test drive
60 Second Review
Problems at Break Neck…
Checking the request’s status
The request URL is a relative URL
The browser always runs your callback… …and it did report an error.
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?
A synchronous request for cola
An asynchronous request for cola
Break Neck Pizza is an asynchronous app
But it was probably too fast for you to notice…
What does asynchronous get you?
Building an Ajax-powered coffee maker
Two coffee makers……and a whole office of caffeine addicts
You’re going to build an Ajax application to allow your co-workers to order their coffee online.
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
Yes, let’s put your JavaScript in a separate file.
Here’s what we did…
Sending a request for coffee
Writing JavaScript to send the request
Which coffee maker should we use?
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
What you want: to get the text in the “coffeemaker1-status”
More help from text-utils.js
Checking a coffee maker’s status
Setting the text in a
Test drive
Let’s clear the form when an order is placed
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
Yes, let’s change sendRequest() first
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
The browser organizes your markup into a “tree” structure.
How the browser sees your HTML (part 2)
WRITE YOUR OWN Web Dictionary
Order matters to the web browser.
Back to the forest
Browsers see the world upside down
A new type of tree: the DOM tree
Remember that big huge DOM tree we just looked at?
Moving around in a DOM tree
The node knows… pretty much everything.
You can! (well, sort of)
Some browsers don’t recognize Node
You’re ready for the challenge…
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
Remember how we added the event handler?
Testing addToTop5()
An element can have only one parent
Exactly!
Adding the ranking number
More additions to our DOM tree
What’s left to do?
Completing addToTop5()
Testing the CD rankings (again)
Now you just need to update top5.html, and set the “Start Over” button to call your completed startO
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…
Error messages are a good thing
The PHP code creates a new response header:
The server talks back
Break Neck error handling
GET requests versus POST requests
GET requests send data in the request URL
POST requests send data separate from the request URL
Web servers unencode POST data
Send more data with a POST request
Browsers cache GET requests
Browsers hate a mystery
Browsers don’t try and cache POST requests.
Trying out POST requests
Why didn’t the POST request work?
The mysterious POST data
You need to set the content type
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
It’s browser-dependent
Well, it’s not that small…
Hmmm…. well… umm….
Break Neck Pizza online
Welcome to SQL injection
It’s still your web application
Protecting against SQL injection in your JavaScript
You still need to secure the PHP script
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
But do you understand why?
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.
XML is a standard… …but how you use it isn’t.
That’s right.
You’ve really got this stuff down!
Why would you do that?
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.
So which is the better data format?
We did say that JSON is JavaScript
JSON comes across as text
You should use text data for your requests whenever possible.
You can use JSON, XML, or text in your requests to the server
JSON is great with objects… …but do you really need objects?
So which is the better data format?
Appendix 1: A Few Special Bonus Gifts: Extras
#1: Ajax toolkits
#2: script.aculo.us and other UI libraries
#3: Inspecting the DOM
Inspecting the DOM in Internet Explorer
Inspecting the DOM in Safari
#4: Using JSON libraries in your PHP scripts
#5: Using eval() with JSON
Use a JSON parser
Appendix 2: “All I Want Is the Code.”: ajaz and DOM utilities
ajax.js
Using ajax.js
Don’t use what you don’t understand
text-utils.js
Using text-utils.js
People also search for:
head rush ajax pdf
ajax head first
ej rush
gh’s rush
Tags: Brett Mclaughlin, Head rush Ajax, Ajax 1st


