Skip to Main Content
Head Rush Ajax
book

Head Rush Ajax

by Brett McLaughlin
March 2006
Beginner to intermediate content levelBeginner to intermediate
448 pages
13h 33m
English
O'Reilly Media, Inc.
Content preview from Head Rush Ajax
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
Head First Ajax

Head First Ajax

Rebecca M. Riordan

Publisher Resources

ISBN: 0596102259Errata PageSupplemental Content