Section 2.3. Break Neck Pizza, Ajax-style


2.3. Break Neck Pizza, Ajax-style

Instead of starting with old 1990s development ideas, let's look at what the Break Neck app should do. Then you can use your new asynchronous programming skills to make sure Break Neck's order form is a responsive, customer-friendly means of getting great pizza, fast. Here's how things should work:

The customer starts out by entering his phone number.

The order form then fills in the customer's address automatically.

The customer enters their pizza order into the form, without waiting on their address to get filled in.

Once the customer has entered in his order, he clicks "Order Pizza"...

...and Alex, the delivery boy, can get the hot pizza right to the customer's front door.

Yeah, come on over, the pizza's already here. Unbelievable... it can't have been ten minutes, and I didn't even have to enter my address.

Work It Through

Just like the Boards 'R' Us application in Chapter 1, you're going to need several JavaScript functions to make the Break Neck appwork. Below on the left are the names of two JavaScript functions, and on the right are several lines of JavaScript. Draw arrows from the lines of code to the function each line of code should go into.

                             request.send(null)  ;                             if (request.readyState == 4) { ... }     getCustomerInfo()                             request.open("GET", url, true);                                 request.onreadystatechange = updatePage;     updatePage()                                  var phone = document.getElementById("phone").value;                                 if (request.status == 200) { ... } We've done one to help you get started. You don't need to write any code... just draw lines from the code to what function that code goes in. 

Answers on page 125.





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