Prev | Current Page 86 | Next

Larry Ullman

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

With
nonsupported browsers, ajax will
have a value of false, and this conditional
will be false.
window.onload = init;
function init() {
var ajax = getXMLHttpRequestObject();
if (ajax) {
Create a new JavaScript fi le that starts with the following code (see extra bits
on page 124):
enabling an Ajax search 103
4 Next, the function checks to see if the browser supports
the Document Object Model (DOM) and, specifi cally, if the
page has an element with an id of results.
5 Finally, an onsubmit() event is attached to the form
(which has an id value of search_form). In other words,
when the form is submitted, do the following??¦
if (document.getElementById(???results??™)) {
document.getElementById(???search_form??™).onsubmit
= function() {
apply the Ajax layer (cont.)
104 enabling an Ajax search
set up the Ajax
1 Provide to the ajax object the name of the page that should be
sent the request. This is search_results_xml.php, to be written
next. The request will be made using the get method.
2 As part of that request, the last_name
value (the letters the user entered in the
form) will be passed along in the URL.


Pages:
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98