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