36
Chapter 1
So now you’ve taken care of talking to the server, and you’re
ready to get the server’s response, and update the Boards
report with new numbers. It’s time to write updatePage().
Remember what this function is supposed to do?
Step 3: Coding updatePage()
updatePage() gets the server’s
response...
...and then updates the
numbers in the web report.
Now the server’s response only has
the number of boards sold in it.
How can your updatePage() function get the response from Katie’s PHP script?
Remember, the request to the script was made in getBoardsSold()... and this is
supposed to be an asynchronous application. That means Katie shouldn’t have to
wait around while the server is getting new sales totals.
So how does updatePage() get the response from the server? Think about this for
a minute or two, and then turn the page.
brain
power
<script>
var request...
function
updatePage() {
...
}
</script>
Updated Number
of Boards Sold
Boards
Sold
Cash for
Slopes
updatePage()createRequest() getBoardsSold()
updating the web report