Mercurial > boosterpack
diff perltest/index.html @ 0:477258d09353 boosterpack
[svn r1] initial import
author | robert |
---|---|
date | Sun, 30 Aug 2009 02:19:26 -0400 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/perltest/index.html Sun Aug 30 02:19:26 2009 -0400 1.3 @@ -0,0 +1,45 @@ 1.4 +<html> 1.5 +<head> 1.6 +<title>Simple Ajax Example</title> 1.7 +<script language="Javascript"> 1.8 +function xmlhttpPost(strURL) { 1.9 + var xmlHttpReq = false; 1.10 + var self = this; 1.11 + // Mozilla/Safari 1.12 + if (window.XMLHttpRequest) { 1.13 + self.xmlHttpReq = new XMLHttpRequest(); 1.14 + } 1.15 + // IE 1.16 + else if (window.ActiveXObject) { 1.17 + self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); 1.18 + } 1.19 + self.xmlHttpReq.open('POST', strURL, true); 1.20 + self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 1.21 + self.xmlHttpReq.onreadystatechange = function() { 1.22 + if (self.xmlHttpReq.readyState == 4) { 1.23 + updatepage(self.xmlHttpReq.responseText); 1.24 + } 1.25 + } 1.26 + self.xmlHttpReq.send(getquerystring()); 1.27 +} 1.28 + 1.29 +function getquerystring() { 1.30 + var form = document.forms['f1']; 1.31 + var word = form.word.value; 1.32 + qstr = 'w=' + escape(word); // NOTE: no '?' before querystring 1.33 + return qstr; 1.34 +} 1.35 + 1.36 +function updatepage(str){ 1.37 + document.getElementById("result").innerHTML = str; 1.38 +} 1.39 +</script> 1.40 +</head> 1.41 +<body> 1.42 +<form name="f1"> 1.43 + <p>word: <input name="word" type="text"> 1.44 + <input value="Go" type="button" onclick='JavaScript:xmlhttpPost("./simple-ajax-example.cgi")'></p> 1.45 + <div id="result"></div> 1.46 +</form> 1.47 +</body> 1.48 +</html>