3 A new PHP script will be written on pages 32-34. This script will return the
results of the Ajax request to the JavaScript.
4 On pages 35 and 36, the second JavaScript page will be completed, handling
the PHP request and updating the HTML page.
5 Next, the HTML page will be modifi ed to include the Ajax layer on page 37.
6 As a last step, on page 38 we??™ll test what we??™ve built to make sure it all works.
At the end of this chapter, in the extra bits section, you??™ll fi nd more
information, tips, and recommendations regarding all of these steps.
26 browsing using Ajax
make a function
One JavaScript fi le will contain all of the code for establishing generic Ajax
functionality. Use any text editing application to make a new JavaScript document.
(See extra bits on page 39.)
1 The JavaScript function is called
getXMLHttpRequestObject() (it??™s
a long but descriptive name). This
function creates a browser-specifi c
XMLHttpRequest object, stored in
the variable ajax.
2 The function assumes no Ajax
support to start (the ajax variable
is initialized with the Boolean
value of false). In the rest of the
function, browsers have to ???prove???
they can take advantage of the Ajax
functionality.
Pages:
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45