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
23
next generation applications
That’s all the server sends back now? I’ll
bet my report will run faster with Ajax!
I’ll have my PHP guy take care of changing
the server-side script right away.
Katie’s server doesn’t
have nearly as much
information to send
back to her web form.
When you’re writing Ajax apps, the server doesn’t need to send all that
HTML back in its response. Since you’ll use JavaScript to update the web
page, all you need from the server is the raw data. In Katie’s app, that
means that all we want is the number of boards sold. Then, you can gure
out the cash that Katie has made with some simple JavaScript.
What the server should do now
1149
getUpdatedBoardSales-ajax.php
The URL to the
new, Ajax-ready
version of the PHP.
The total number
of boards sold.
A much happier,
stress-free server.
24
Chapter 1
...at a glance
PHP
Katie’s PHP script got a lot simpler when all it needed to do was
return the total number of boards sold. Take a look:
<?php
// Connect to database
$conn = @mysql_connect(“mysql.headrstlabs.com”,
“secret”, “really-secret”);
if (!$conn)
die(“Error connecting to MySQL: “ . mysql_error());
if (!mysql_select_db(“headrst”, $conn))
die(“Error selecting Head First database: “ . mysql_error());
$select = ‘SELECT boardsSold’;
$from = ‘ FROM boar ...
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