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
18
Chapter 1
<script>
var request...
function
getBoardsSold()
{
...
}
</script>
Request Total
Boards Sold
Now that you can get a request object with createRequest(), you’re ready for the
next step: writing the getBoardsSold() JavaScript function. This function will use the
new object to request the total number of boards sold from the server. Let’s gure out what
this function needs to do, and then we can get back to coding Katie’s app. Remember our
diagram? Here’s the step we’re working on:
Here’s what you’ll need to do to make getBoardsSold() work:
Step 2: Requesting updated sales
Set up the request object to make a
connection.
Request an updated number of
boards sold.
Figure out what URL you need to
connect to so you can get updated
board sales.
Create a new request object by calling
the createRequest() function.
You can use the pre-assembled
JavaScript from the last two
pages to take care of this.
You can use this number
later, in Step 3, when you
update the page with new
values. You’ll tackle this in
just a little while.
Here’s where you’ll use
that request object you
created in createRequest().
Katie already has this URL in her
form, so this should be simple enough.
Open up your boards.html le, and add a new JavaScript function called getBoardsSold(),
right after createRequest(). Then, see if you can add a line of JavaScript in
getBoardsSold() to create a new request object (that’s Step ...
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