comparison BoosterPack/perltest/.svn/text-base/index.html.svn-base @ 0:0d795f02a8bb tip

initial committ. what was I thinking?
author Robert McIntyre <rlm@mit.edu>
date Mon, 27 Sep 2010 16:57:26 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0d795f02a8bb
1 <html>
2 <head>
3 <title>Simple Ajax Example</title>
4 <script language="Javascript">
5 function xmlhttpPost(strURL) {
6 var xmlHttpReq = false;
7 var self = this;
8 // Mozilla/Safari
9 if (window.XMLHttpRequest) {
10 self.xmlHttpReq = new XMLHttpRequest();
11 }
12 // IE
13 else if (window.ActiveXObject) {
14 self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
15 }
16 self.xmlHttpReq.open('POST', strURL, true);
17 self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
18 self.xmlHttpReq.onreadystatechange = function() {
19 if (self.xmlHttpReq.readyState == 4) {
20 updatepage(self.xmlHttpReq.responseText);
21 }
22 }
23 self.xmlHttpReq.send(getquerystring());
24 }
25
26 function getquerystring() {
27 var form = document.forms['f1'];
28 var word = form.word.value;
29 qstr = 'w=' + escape(word); // NOTE: no '?' before querystring
30 return qstr;
31 }
32
33 function updatepage(str){
34 document.getElementById("result").innerHTML = str;
35 }
36 </script>
37 </head>
38 <body>
39 <form name="f1">
40 <p>word: <input name="word" type="text">
41 <input value="Go" type="button" onclick='JavaScript:xmlhttpPost("./simple-ajax-example.cgi")'></p>
42 <div id="result"></div>
43 </form>
44 </body>
45 </html>