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: