you’re on your way 4
165
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
PHP script
HTML form
<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()
w Code to create a request object.
w A function to send an order to the
coffee-making script.
w A function to serve a drink when it’s
been brewed.
w An event handler to connect the ”Order
Coffee” button to these JavaScript functions.
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.
We can get the user’s order, but
still need to check the status of
the coffee makers and gure out
which one to send the order to.
We’ve got this done also. When
someone clicks “Order Coffee”, our
orderCoffee() function runs.
We still have to write
this function. It needs to
get the server’s ...