If the browser supports the XMLHttpRequest object as
a window property (all common browsers do except IE 5 and 6), the code
can call the XMLHttpRequest constructor. If the browser implements
the XMLHttpRequest object as an ActiveXObject object (as in IE
versions 5 and 6), the code uses the ActiveXObject constructor. The
function below calls an init() function, which checks to determine the
appropriate creation method to use before creating and returning the
object.
Next, we need to initialize the XMLHttpRequest object using the
open() method, specifying the HTTP method and the server URL to use.
var catalogId=encodeURIComponent(
document.getElementById(???catalogId???).value);
xmlHttpReq.open(???GET???, ???validateForm?catalogId=??? +
catalogId, true);
HTTP requests sent with XMLHttpRequest are asynchronous by
default, but the async parameter may be explicitly set to true as shown
above.
In this case, the call to the URL validateForm invokes a servlet on
the server-side, but it should recognized that the server-side technology is
immaterial; the URL might actually be an ASP, ASP.NET, or PHP page,
or a Web service??”it doesn't matter as long as the page returns a response
indicating whether the CatalogID value is valid.
Pages:
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36