114
Chapter 2
When you’re writing synchronous
applications, you can usually put your elds
on a form in whatever order you like. But for
synchronous applications like Break Neck,
you’re going to have to think a little harder
about how your form should look.
In the Break Neck order form, you probably
don’t want customers to start entering their
address, and then have your callback function
overwrite that with the address from the
server. Instead, let’s re-order the form, so
customers go from the phone number eld to
the order eld. That way, customers can start
entering their pizza order while their address
is being looked up.
Order matters in asynchronous apps
I was typing in my address before
updatePage() got a response and lled it
in. That seems sort of confusing... and
annoying! Can’t we x that?
Go ahead and ip
these two elds in
your pizza.html le.
Now customers will enter their
order after typing in their
phone number. By the time
they’re done, their address
will have already appeared.
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
changing the user interface