Skip to Content
Head Rush Ajax
book

Head Rush Ajax

by Brett McLaughlin
March 2006
Beginner to intermediate
448 pages
13h 33m
English
O'Reilly Media, Inc.
Content preview from Head Rush Ajax
104
Chapter 2
Under the Microscope:
So when exactly does the ready state of a request
change? Here’s a close-up look at the ready state
of a request, and how it changes as a request is
processed by a web server.
HTTP Ready States
getCustomerInfo() calls open()
on the request object, and
initializes the connection.
The JavaScript function
you assigned to the
onreadystatechange property is
run, and can use the server’s data.
0
Connection
uninitialized
var request = ...
<script>
var request...
function foo()
{
...
}
</script>
updatePage()
Web Page
JavaScript
This JavaScript function can
update the HTML page using the
response data from the server.
When the web page is
loaded, a new request
object is created.
<script>
var request...
function foo()
{
...
}
</script>
JavaScript
getCustomerInfo()
Here’s the request object’s
ready state, stored in the
readyState property.
This is the callback function that
you just learned about...
http ready states
Man, Break Neck pizza rocks. There’s
nothing like a breakfast of cold pizza, a
whipped latte from Starbuzz, and the
Webville Times to read.
<script>
var request...
function foo()
{
...
}
</script>
JavaScript
<script>
var request...
function foo()
{
...
}
</script>
Customer’s Phone Number
Customer’s Address
Customer’s Order
request.open(“GET”, url, true);
you’re on your way 4
105
ajax requests ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally

Publisher Resources

ISBN: 0596102259Errata PageSupplemental Content