you’re on your way 4
103
ajax requests
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
Step 3: Retrieve the customer’s address
In this step, we need to use the address that the Break Neck PHP
script will return in response to the request we made in Step 2.
Then, we can have the browser run a JavaScript function once
it has a response from the Break Neck server, and pass along the
address from the script.
<script>
var request...
function foo()
{
...
}
</script>
Customer’s Address
Web Server
We’ll need to write this JavaScript
function. It can get the server’s
response from the request object you
created back in Step 2.
Remember, it’s the browser that gets
the response from the server. Then, it
“calls back” the JavaScript function you
specied in your request object.
Here’s where the browser
runs your callback function.
The Break Neck PHP script looks
up the customer by his phone
number, and returns his address.
The browser runs your callback function every time
the ready state of your request object changes.
On to the next step in
coding Break Neck.