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
286
Chapter 5
Now that the Break Neck PHP script just returns a delivery estimate,
we can write a new JavaScript function to display this to the customer.
Let’s gure out exactly what we need to do.
4. Write the callback function
An HTML page with a main
<div>, and a <form> within
that <div> for taking orders.
What we have:
An HTML page with a
main <div>, and an order
conrmation within that <div>.
What we want:
Replace the <form> in the
main <div> with the order
conrmation.
What we
need to do:
1.
Get a reference to the <div> in the
page, using its “id” attribute.
2.
Get a reference to the <form> in the
page, using its “id” attribute.
3.
Create a new <p> element, and add a
text confirmation of the order to the <p>.
4.
Replace the <form> element with the
new <p> element (and its text node).
<div>
<div>
<form>
Here’s the main <div>
for the page, with an
id of “main-page”.
The <form> has an id,
“order-form”, that we can
use to look the <form>
element up in the DOM.
This is the same <div> as in
the original order form...
...but we’ve replaced
the <form> with
a text order
conrmation.
form
div
p
Order conrmation
p
<p>
Send Order
HTML Form
PHP Script Callback
Let’s look at this step in a little more detail.
another break neck callback
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