Skip to Content
Head Rush Ajax
book

Head Rush Ajax

by Brett McLaughlin
March 2006
Beginner to intermediate
448 pages
13h 33m
English
O'Reilly Media, Inc.
Content preview from Head Rush Ajax
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally

Publisher Resources

ISBN: 0596102259Errata PageSupplemental Content