Witten
Bainbridge
Nichols
HOME HELP PREFERENCES SEARCHFIGURESTABLES

Using AJAX to retrieve information from the server

 1 package depositor
 2
 3 _httpchecksum_ {_httpprefix_/cgi-bin/checksum.cgi}
 4
 5 _pagescriptextra_ {
 6
 7   function urlGetAsync(url,elem)
 8   \{
 9      var xmlHttp;
10      try \{
11        // Firefox, Opera 8.0+, Safari
12       xmlHttp=new XMLHttpRequest();
13     \}
14     catch (e) \{
15       // Internet Explorer
16       try \{
17         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
18       \}
19       catch (e) \{
20         try \{
21           xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
22         \}
23         catch (e) \{
24           alert("Your browser does not support AJAX!");
25           return false;
26         \}
27       \}
28     \}
29
30     xmlHttp.onreadystatechange=function() \{
31       if(xmlHttp.readyState==4) \{
32         if (locelem != null) \{
33           var locelem = document.getElementById(elem);  
34           locelem.innerHTML = xmlHttp.responseText;
35         \}
36       \}
37     \}
38   
39      xmlHttp.open("GET",url,true);
40      xmlHttp.send(null);
41   \}
42
43   function add\_checksum(filename)
44   \{
45       urlGetAsync("_httpchecksum_?filename="+filename,"pane1");
46   \}
47 }

Figure 12.8c: Using AJAX to retrieve information from the server; AJAX JavaScript code for asynchronous loading