30
Chapter 1
All right! You’ve got a request object, a URL, and your connection
is initialized and ready to go. Now you just need to make the
connection, and request the updated number of boards sold. To
do that, just call send() on the request object:
function getBoardsSold() {
createRequest();
var url = “getUpdatedBoardSales-ajax.php”;
request.open(“GET”, url, true);
request.send(null);
}
You’re sending the
request here...
...and this means that you’re not sending
any data in the request. The script
doesn’t need any data; it just returns
the total board sales, every time it’s run.
In this particular app, you don’t need to provide
the server with any information. Each request to
the PHP script asks for the same thing: a single
number, the total number of boards that Katie
has sold. So you don’t need to send the server
anything but null in your request.
The server doesn’t need any data.
Are you kidding me? We did all this work,
and you’re telling me I’m sending null to
the server? This is what you call next-
generation programming?
Connecting to the web server
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.
Here’s our checklist from page
28... only one item left to go.
We’re working on this last task now. ...