|
//****************没有用到Prototype
function ajaxHTML(){
//创建XMLHttpRequest对象
var xmlhttp;
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
//创建请求结果处理程序
xmlhttp.onreadystatechange=function(){
if (4==xmlhttp.readyState)
{
if (200==xmlhttp.status)
{
var resp= xmlhttp.responseText;
document.getElementById("lbMsg").innerHTML = resp;
}
else
{
alert("error");
}
}
}
//打开连接,true表示异步提交
xmlhttp.open("get", "data.asp", true);
//发送数据
xmlhttp.send();
}
<input type="button" name="tt" value="tt" onclick="ajaxHTML();">
<div id="lbMsg"></div>
data.asp
<%
Response.CharSet="gb2312"
response.write("<br>1信息!</br><br>2信息!</br><br>3信息!</br>")
%>
显示结果:
1信息!
2信息!
3信息!
|