Section 2.2. Solving the pizza delivery problem


2.2. Solving the pizza delivery problem

Fortunately, web developers have been solving these sorts of problems for years. Instead of letting users enter their own address (and type something incorrectly), let's look up the customer's address in the Break Neck customer database. Then, Alex will always get the right delivery address. Here's what we can do:

  1. The customer enters their phone number

    A customer enters his phone number, and the phone number gets sent to Break Neck's web server.

         Break Neck's server     Customer's phone number     Customer's phone number     New HTML with customer info filled in 

  2. The server fills in the customer's details

    The server sends back a new form, with the customer's name, phone number, and address already entered into the HTML.

         The new form has the customer's phone and address already filled in.     The customer can make sure his address is right, but shouldn't have to type it in     manually, and run the risk of making mistakes. 

  3. The customer enters their order

    With the customer's details filled in, he can enter his pizza order into the form, and click "Complete Order".

         Finally, an order form with the right address! 

  4. The server sends a delivery request

    The customer's name, address, and phone number are sent to Alex, the delivery guy, along with the customer's pizza order, ready for delivery.

         Here's the customer's pizza order.     Customer's pizza order Order 

Umm... hello? I thought this was an Ajax book... why aren't we using asynchronous requests here? And the customer has to wait around while the server looks up his address? That's not very Break Neck!

2.2.1. No kidding!

It looks like Ajax is just the thing to help out Break Neck. Let's look up that address without making the customer wait around for the server... and solve Alex's delivery woes, all at the same time.




Head Rush Ajax
Head Rush Ajax (Head First)
ISBN: 0596102259
EAN: 2147483647
Year: 2004
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net