Prev | Current Page 93 | Next

Larry Ullman

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

With each iteration
of the loop, the counter, i, is incremented.
4 Each employee returned by the PHP
page will be put within an HTML paragraph
(see the HTML source code on the previous
page). So, within the loop, the fi rst step is
to create a new element of type p. This step
adds a paragraph to the DOM, although the
paragraph doesn??™t yet have anything in it,
nor has it been placed on the page.
for (var i = 0; i < names.length; i++) {
employee = document.createElement(???p??™);
enabling an Ajax search 115
The employee??™s name should be put within a span whose class attribute is
name. This should be followed by a break.
1 Another element, of type
span, is created. (See extra
bits on page 127.)
2 The class attribute of the
span is given a value of name.
So the text put within the span
(see the next two steps) will be
formatted as a name.
3 A di?¬? erent kind of node, a text
node, is created. The value of
the text node (which is to say the
actual text) will be the value of the
name returned in the XML data.
4 The text node is made a child
of the span node. Therefore, the
text node (which is the employee??™s
name) is within the span.


Pages:
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105