you’re on your way 4
33
Do you see what you need to do? When Katie clicks the “Show Me the Money”
button, the web form submits everything to the PHP script. But we don’t want
the web form to get submitted, because we’re using Ajax to handle requests to the
server. This shouldn’t be too hard to x, though.
Let’s go back to the HTML for the Boards ‘R’ Us report:
Back to the HTML
<body>
<h1>Boards ‘R’ Us :: Customer Boards Report</h1>
<div id=”boards”>
<table>
<tr><th>Snowboards Sold</th>
<td><span id=”boards-sold”>1012</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”>167718.76</span></h2>
<form method=”GET” action=”getUpdatedBoardSales.php”>
<input value=”Show Me the Money” type=”submit” />
</form>
</div>
</body>
This button
shouldn’t submit
the form
anymore...
<input value=”Show Me the Money” type=”button” />
...so you can change it to be
just a normal input button.
This is just the
HTML in the
<body> tag...
we’ve left the
rest of the
le off.
updatePage()createRequest() getBoardsSold()
Q:
Couldn’t we remove the action from the <form> tag,
instead of changing the button type?
A: That’s a good idea, in addition to changing the button type.
If you only remove the action, though, the “Show Me the Money”
button will ...