(See extra bits
on page 40.)
1 The init() function next 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.
2 If the browser supports it, an
onsubmit() event is attached
to the form (which has an id
value of dept_form). In other
words, when the form is submitted,
do the following??¦
??¦
if (ajax) {
if (document.getElementById(???results??™)) {
document.getElementById(???dept_form??™).onsubmit =
function() {
var did = document.getElementById(???did??™).
value;
30 browsing using Ajax
3 Provide to the ajax object the name of the page that should be sent
the request. This is dept_results_ajax.php, to be written next. The
request will be made using the get method.
4 As part of that request, the department ID value (from the form) will
be passed along in the URL.
5 When the ajax object??™s readyState value changes, the
handleResponse() function should be called, passing that
function this same ajax object.
6 Then the actual Ajax request is made.
7 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).
Pages:
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48