<script type="text/javascript">
var xmlHttp;
//先新建一XHR对象
function createXMLHttpRequest() {
//如果是IE,用activexobject
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
//如果其它浏览器就用XMLHttpRequest
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
//开始函数
function startRequest() {
createXMLHttpRequest();
//指定当readyState属性改变时执行的函数
xmlHttp.onreadystatechange = handleStateChange;
//创建一个新的http请求,并指定此请求的方法、URL以及验证信息
xmlHttp.open("GET", "simpleResponse.xml", true);
//发送请求到http服务器并接收回应
xmlHttp.send(null);
}
function handleStateChange() {
//4数据接收完毕
if(xmlHttp.readyState == 4) {
//200返回请求状态为OK
if(xmlHttp.status == 200) {
//弹出对话框,并输入simpleResponse.xml文件的文本内容
alert("The server replied with: " + xmlHttp.responseText);
}
}
}
</script>
var xmlHttp;
//先新建一XHR对象
function createXMLHttpRequest() {
//如果是IE,用activexobject
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
//如果其它浏览器就用XMLHttpRequest
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
//开始函数
function startRequest() {
createXMLHttpRequest();
//指定当readyState属性改变时执行的函数
xmlHttp.onreadystatechange = handleStateChange;
//创建一个新的http请求,并指定此请求的方法、URL以及验证信息
xmlHttp.open("GET", "simpleResponse.xml", true);
//发送请求到http服务器并接收回应
xmlHttp.send(null);
}
function handleStateChange() {
//4数据接收完毕
if(xmlHttp.readyState == 4) {
//200返回请求状态为OK
if(xmlHttp.status == 200) {
//弹出对话框,并输入simpleResponse.xml文件的文本内容
alert("The server replied with: " + xmlHttp.responseText);
}
}
}
</script>
浙公网安备 33010602011771号