Mercurial > boosterpack
view perltest/index.html @ 7:4c495190076f boosterpack
[svn r9] fixed blanes dodrio bug
author | robert |
---|---|
date | Thu, 10 Sep 2009 08:01:18 -0400 |
parents | 477258d09353 |
children |
line wrap: on
line source
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/Safari9 if (window.XMLHttpRequest) {10 self.xmlHttpReq = new XMLHttpRequest();11 }12 // IE13 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 }26 function getquerystring() {27 var form = document.forms['f1'];28 var word = form.word.value;29 qstr = 'w=' + escape(word); // NOTE: no '?' before querystring30 return qstr;31 }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>