Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; CHARSET=GBK "/>
<title>getting Server side Data using ajax</title>
<script>
function Creat_object () {
var xmlhttp;
if (!xmlhttp && typeof xmlhttprequest!= ' undefined ') {
try {
XMLHTTP = new XMLHttpRequest ();
}
catch (e) {
Alert ("Your browser is not supporting XMLHttpRequest"); <BR> xmlhttp = false;
}
}
else {
XMLHTTP = new ActiveXObject ("Microsoft.XMLHTTP");
}
return XMLHTTP;
}
var request = Creat_object ();
function Sever_interaction () {
if (request.readystate = = 1) {
document.getElementById (' aja_cnts '). Value = ';
document.getElementById (' aja_cnts '). Value = ' Loading ... ';
}
if (request.readystate = = 4) {
var answer = Request.responsetext;
document.getElementById (' aja_cnts '). Value = ';
document.getElementById (' aja_cnts '). Value = Answer;
}
}
function Call_server () {
Request.open ("Get", "response.asp");
Request.onreadystatechange = sever_interaction; Request.send (");
}
</script>
<body>
<input type= "button" Name= "Btnload" id= "Btnload" value= "click Load" onclick= "Call_server ();"/>
<input type= "text" style= "WIDTH:265PX; height:68px "id=" aja_cnts "/>
</body>
Get page response.asp code: document.getElementById (' aja_cnts '). Value
Response.asp code Example:
Copy Code code as follows:
<%
Response.Write "Hello!" Welcome to Yau 9 Store! "
Response.Write "Our website is: http://you9luck.taobao.com"
%>