Section 3.16. What JavaScript do we still need to write?


3.16. What JavaScript do we still need to write?

There's a lot of JavaScript that you'll need to write to make the coffee maker work like it's supposed to. Let's take a look at all the functions we've got to code, and review what we still need to do:

JavaScript code

You'll need some JavaScript, including:

  • Code to create a request object.

    This code is done, and in ajax.js. It's the same code that we used in Chapter 2, and creates the request object in static JavaScript.

  • A function to send an order to the coffee-making script.

    We can get the user's order, but still need to check the status of the coffee makers and figure out which one to send the order to.

  • A function to serve a drink when it's been brewed.

    We still have to write this function. It needs to get the server's response, and set the status of the coffee maker that just finished brewing back to "Idle".

  • An event handler to connect the "Order Coffee" button to these JavaScript functions.

    We've got this done also. When someone clicks "Order Coffee", our orderCoffee() function runs.

 <html> <head> <title>Break Neck Pizza Delivery</title> <link rel="stylesheet" type="text/css" href="breakneck.css" /> <script language="javascript" type="text/javascript"> var request = null; function createRequest() { try { request = new XMLHttpRequest(); } catch (trymicrosoft) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { You'll need some JavaScript, including: JavaScript code JavaScript orderCoffee() serveDrink() 

* Don't forget, we've still got to get a coffee-making script running on the server, too. We'll get to that in a little bit.




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