#2
rainic2006-12-22 23:07
|
代码如下:
var xmlHttp;
//创建XMLHttpRequest对象
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if( window.XMLHttpRequest ){
xmlHttp = new XMLHttpRequest();
}
}
//发送请求
function startRequest(){
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET","simpleRequest.xml",true);
xmlHttp.send(null);
}
//处理响应
function handleStateChange(){
if( xmlHttp.readyState == 4 ){
{
if( xmlHttp.status == 200 ){
alert("Server response with:"+xmlHttp.responseText);
}
}
}
}
运行后无预期结果-------弹出提示窗口.而将处理响应函数改为如下后就可以:
function handleStateChange(){
if( xmlHttp.readyState == 4 ){
{
alert("Server response with:"+xmlHttp.responseText);
}
}
}
请教这是什么原因啊?