148
Chapter 3
1
Let’s say that Jim wants to get a caffeine x. He enters his name into the web
form, selects Large and Mocha, and then clicks “Order Coffee”. This causes
your JavaScript to run, which then sends a request to the rst coffee maker.
2
While the rst coffee maker is brewing coffee for Jim, Mary decides she
needs some cappucino to keep her going. Good thing this is an asynchronous
application—she can order a drink from the second coffee maker, even
though the server is still brewing coffee in response to Jim’s earlier request.
The rst coffee
maker is working
on Jim’s order,
and we’ve updated
the status of the
coffee maker.
Make Jim a large mocha
using the rst coffee maker
Clicking on “Order Coffee”
causes the Javascript to send
a request to the server to
brew a cup of coffee.
The server is
still busy brewing
coffee for Jim...
coffeemaker.php
coffeemaker.php
How is the coffee maker going to work?
You should have a good idea of what you’ll need to build the coffee-making
app. Now you just need to be sure you know what the app will do. Before
diving into the actual HTML and JavaScript, let’s take a closer look at how
the coffee maker will handle requests to make a cup of coffee.
JavaScript
Jim enters in
his name and
coffee order.
Since coffee maker 2 is idle, and
this is an asynchronous app, Mary
can place her own coffee order.
JavaScript
Make Mary a medium
cappucino using the second ...