复制代码 代码如下:




Getting Server side data using AJAX


function creat_Object() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != ‘undefined’) {
try {
xmlhttp = new XMLHttpRequest();
}
catch (e) {
alert(“Your browser is not supporting XMLHTTPRequest”);
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(”);
}







获取页面Response.asp代码:document.getElementById(‘aja_cnts’).value
Response.asp代码示例:
复制代码 代码如下:
<%
Response.Write “您好!欢迎光临悠9小店!”
Response.Write “我们的网址是:http://you9luck.taobao.com”
%>