כלים אישיים
הנך נמצא כאן: עמוד בית Faq שירותים אינטרנט indexajax.html

indexajax.html

indexajax.html — HTML, 1 kB (1243 bytes)

תוכן קובץ

<html>
<head>
<title>Simple Ajax Example</title>
<script language="Javascript">
function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
        if (window.XMLHttpRequest) {
       	 self.xmlHttpReq = new XMLHttpRequest();
	    }
    // IE
	else if (window.ActiveXObject) {
	 self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	 self.xmlHttpReq.open('POST', strURL, true);
	 self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 self.xmlHttpReq.onreadystatechange = function() {
	if (self.xmlHttpReq.readyState == 4) {
	   updatepage(self.xmlHttpReq.responseText);
	    }
											    }
       self.xmlHttpReq.send(getquerystring());
	}
function getquerystring() {
 var form     = document.forms['f1'];
 var word = form.word.value;
 qstr = 'w=' + escape(word);  // NOTE: no '?' before querystring
return qstr;
}
function updatepage(str){
   document.getElementById("result").innerHTML = str;
    }
</script>
</head>
 <body>
 <form name="f1">
 <p>word: <input name="word" type="text" onkeyup='JavaScript:xmlhttpPost("http://www.cs.tau.ac.il/cgi-bin/cgiwrap/boazya/simple-ajax-example.cgi")'></p>
 <div id="result"></div>
 </form>
</body>
 </html>

פעולות מסמך