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
25
next generation applications
This is the URL of the Ajax-
ready version of the PHP script.
function getBoardsSold() {
createRequest();
var url = “getUpdatedBoardSales-ajax.php”;
}
This takes care of creating
the new request object.
Here’s your
JavaScript
function.
updatePage()createRequest() getBoardsSold()
It’s time to give Katie’s PHP script an Ajax upgrade. Open up the examples, and nd
getUpdatedBoardSales-ajax.php in the chapter01/boards/ directory. This is a
version of getUpdatedBoardSales.php that only returns the number of boards sold, without
any HTML in the response. It also works without a database, so you don’t need to set one up to use
this PHP script. Make sure this le is in the same directory as your boards.html le; we’ll be
using this new version of the script in just a moment.
The new script’s URL
Now that you’ve got a PHP script that only returns the number of boards
sold, instead of a bunch of HTML, we just need to make a request to that
script. Remember, you want to send your request to the new version of the
PHP script, and only returns the sales total, not an entire HTML page.
Store the URL of this new PHP script in a JavaScript variable, like this:
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