(See
extra bits on page 124.)
3 When the ajax object??™s readyState
value changes, the handleResponse()
function should be called, passing that
function this same object.
??¦
document.getElementById(???search_form??™).onsubmit =
function() {
var last_name = document.getElementById(???last_
name??™).value;
ajax.open(???get??™, ???search_results_xml.php?last_name=??™
+ encodeURIComponent(last_name));
ajax.onreadystatechange = function() {
handleResponse(ajax);
}
enabling an Ajax search 105
complete the function
1 The actual Ajax request is made.
2 Finally, the function returns a value of false to tell the Web
browser not to actually submit the form (since the Ajax is handling
the form submission).
Save this fi le as
search.js and
place it in the same
directory on your
Web server as
every other fi le.
??¦
handleResponse(ajax);
}
ajax.send(null);
return false;
} // End of anonymous function.
} // End of DOM check.
} // End of ajax IF.
} // End of init() function.
106 enabling an Ajax search
prepare for XML
A new PHP script will do the same thing as search_results.php, only it will
return all of its results as XML data.
Pages:
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99