Prev | Current Page 97 | Next

Larry Ullman

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


4 The text node is made a child of the paragraph node.
5 The paragraph is made a child of the results DIV,
thereby putting the paragraph onto the page.
??¦
} // End of FOR loop.
} else { // No employees, print a message.
var node1 = document.createElement(???p??™);
node1.setAttribute(???class??™, ???error??™);
var node2 = document.createTextNode(???No employees
were a match.??™);
node1.appendChild(node2);
results.appendChild(node1);
}
enabling an Ajax search 121
complete the function
If we didn??™t get a valid status code back from the Ajax request, we should
formally submit the form to the handling PHP page (as if the Ajax layer
didn??™t exist at all).
??¦
results.appendChild(node1);
}
} else { // Bad status code, submit the form.
document.getElementById(???search_form??™).submit();
}
} // End of readyState IF.
} // End of handleResponse() function.
122 enabling an Ajax search
test the Ajax layer
1 Load the HTML page in your Web browser.
The address must begin with http:// for this to work.
2 Enter a letter or two
and click GO.
3 The HTML page should show the results without
reloading the page or going to a new page.


Pages:
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109