87,989
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
var xmlHttp;
//创建一个XmlHttpRequeset对象
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
var result;
//开始一个请求
function startRequest(){
createXMLHttpRequest();
xmlHttp.onreadystatechange = handlestatechange;
xmlHttp.open("GET", "SimpleRespose.xml", true);
xmlHttp.Send(null);
//用什么办法让handlestatechange执行完在走alert
alert("结果:" + result);
}
function handlestatechange(){
if(xmlHttp.readyState == 4){//描述一种"已加载"状态;此时,响应已经被完全接收。
if(xmlHttp.status == 200){//200表示成功收到
alert("The Server Replied with:" + xmlHttp.responseText)
}
}
}
startRequest();
</script>
xmlHttp.open("GET", "SimpleRespose.xml", false);