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
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
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