Prev | Current Page 68 | Next

Larry Ullman

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

getElementById(???department_id_label??™).
className = ???title??™;
document.getElementById(???phone_ext_label??™).className
= ???title??™;
76 adding records via Ajax
handle the XML
1 The XML data returned by the PHP script can be accessed via ajax.
responseXML, which we assign to a variable called data. (See extra
bits on page 86.)
2 The variable message will refer to the XML element with a tag
name of result.
3 The variable errors will
refer to every XML element
with a tag name of error.
??¦
document.getElementById(???phone_ext_label??™).className =
???title??™;
var data = ajax.responseXML;
var message = data.getElementsByTagName(???result??™);
var errors = data.getElementsByTagName(???error??™);
var temp = false;
adding records via Ajax 77
6 The error value is used
to change the class of the
corresponding form label.
for (var i = 0; i < errors.length; i++) {
temp = errors[i].firstChild.nodeValue;
document.getElementById(temp + ???_label??™).className =
???error??™;
}
5 A temporary variable will
be assigned the value of the
error from the XML data.
handle the XML (cont.)
4 Loop through the errors array to access every one.


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