Section 5.2. Submitting a form with Ajax


5.2. Submitting a form with Ajax

Break Neck doesn't seem to be asking for anything that complicated. Let's see if we can convert the Break Neck pizza form submission into an asynchronous request.

Here's what you'll need to do:

     submitOrder() 2Your new JavaScript function, submitOrder(), will submit the customer's order to the Break Neck server asynchronously, using the information in the pizza order form.     showConfirmation()     4In this step, you'll have to write a new callback function. This will need to take the delivery time that you get from the Break Neck server, and give the customer a confirmation that her order is on its way.     1First, you'll need to change the Break Neck HTML: instead of letting a customer place her order with a submit button, the "Order Pizza" button should call a new JavaScript function. You'll write this function in the next step, and call it submitOrder().     3 Break Nech ServerYou'll have to make sure the PHP script on Break Neck's server doesn't send back HTML anymore... instead, it should return how much time it will take for the pizza to arrive at the customer's door. 




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