you’re on your way 4
81
On to the JavaScript
Now you’re ready to dig into some JavaScript. You know the name of
the function that you’ll be using to get the customer’s phone number:
getCustomerInfo(). This function needs to send the customer’s phone
number to Break Neck’s server, and ask for that customer’s address.
Let’s start out with just the function name:
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
function getCustomerInfo() {
...
}
Here’s where all
your code will go.
brain
power
Do you think there could be any problems with
event handlers that run JavaScript code that
then makes asynchronous requests? What
would happen if the pizza form sent a request
for an address, and then sent another request
before the rst response was returned? What
do you think the customer would see happen
on the order form?
Open up the examples for Head Rush Ajax that you
downloaded from http://www.headrstlabs.com. Go
into the chapter02/breakneck/ folder, and you’ll nd
pizza.html. This is the Break Neck order form, but
you need to make some changes to bring it up to
speed.
First, make sure the HTML matches the answers
from the Code Magnets exercise, ...