Prev | Current Page 67 | Next

Larry Ullman

"Building a Web Site with Ajax: Visual QuickProject Guide"

(See extra bits on page 85.)
1 This JavaScript function is called when the
ajax object??™s readyState value changes (see
the init() function). The function receives
the ajax object when called.
2 The function shouldn??™t do anything until
readyState has a value of 4, meaning that
the Ajax transaction is complete.
3 If the status code is equal to either 200 or
304, we can use the returned results.
function handleResponse(ajax) {
if (ajax.readyState == 4) {
if ((ajax.status == 200) || (ajax.status == 304) )
{
adding records via Ajax 75
prepare the page
1 The results variable now refers to
a specifi c area in the DOM (Document
Object Model) of the HTML page.
2 Each of the form??™s labels should have
its class reset to the default class of
title. (See extra bits on page 85.)
??¦
if ((ajax.status == 200) || (ajax.status == 304) ) {
var results = document.getElementById(???results??™);
document.getElementById(???first_name_label??™).
className = ???title??™;
document.getElementById(???last_name_label??™).className
= ???title??™;
document.getElementById(???email_label??™).className =
???title??™;
document.


Pages:
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79