22
Chapter 1
Remember how the non-Ajax version of Katie’s report works? Every time a request
is made to the PHP script, it has to return the number of boards sold, along with an
entirely new HTML page. Flip back a page, and notice that over half the PHP script is
just HTML! Here’s another look at what’s going on:
What the server used to do...
All of the HTML that
the server has to return
for each request.
<html>
<head>
<title>Boards ‘R’ Us</title>
<link rel=”stylesheet” type=”text/css” href=”boards.css” />
</head>
<body>
<h1>Boards ‘R’ Us :: Custom Boards Report</h1>
<div id=”boards”>
<table>
<tr><th>Snowboards Sold</th>
<td><span id=”boards-sold”>1149</span></td></tr>
<tr><th>What I Sell ‘em For</th>
<td>$<span id=”price”>249.95</span></td></tr>
<tr><th>What it Costs Me</th>
<td>$<span id=”cost”>84.22</span></td></tr>
</table>
<h2>Cash for the Slopes:
$<span id=”cash”>190423.27</span></h2>
<form method=”GET” action=”getUpdatedBoardSales.php”>
<input value=”Show Me the Money” type=”submit” />
</form>
</div>
</body>
</html>
All of this HTML, and the
only thing that changed is
the number of boards sold,
and the updated cash total!
HANDLE WITH CARE:
HTML CONTENT
FRAGILE
The URL for
Katie’s script, from
her web form.
updatePage()createRequest() getBoardsSold()
getUpdatedBoardSales.php
Katie’s server,
having to deal
with a lot of
HTML content..
servers that return lots of html