Mercurial > boosterpack
comparison perltest/index.html @ 0:477258d09353 boosterpack
[svn r1] initial import
author | robert |
---|---|
date | Sun, 30 Aug 2009 02:19:26 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:477258d09353 |
---|---|
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> |