108
Chapter 2
You’ve seen what the Break Neck server is doing, and you’re
written a lot of new JavaScript, but what’s the browser doing as
all these ready states are changing?
Let’s take a look and nd out:
What is the browser doing?
Web Browser
Internet Explorer
Firefox
Opera
Safari
Mozilla
1
2
3
4
These are the request’s ready states.
<?php
require(‘lib.php’);
function go() {
$myVar = ...
return ...
}
?>
1
2
<script>
var request...
function foo()
{
...
}
</script>
PHP script
JavaScript
updatePage()
3
4
Request
Object
5
6
1. The browser runs
getCustomerInfo(), and a request is
made to the Break Neck web server.
2. As the request is being worked
on, the ready state of the request
is changed to reect what stage of
processing the request is in.
3. Each time the ready
state of the request
changes, the browser
runs your callback
function, updatePage().
4. updatePage() checks
the request object’s
ready state, and only
keeps running if the
request is nished.
6. If the request is nished,
updatePage() can get the server’s
response from the request object.
5. When the browser gets a
completed response from the
server, it stores the server’s
response in the request object.
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 ...