首页 > 开发 > AJAX > 正文

Ajax通用模板实现代码

2020-07-09 12:22:15
字体:
来源:转载
供稿:网友
复制代码 代码如下:CuoXin.com

<script type="text/javascript">
var xmlHttp;

function creatXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}

}
function startRequest() {
creatXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", "simpleResponse.xml", true);
xmlHttp.send(null);

}
function handleStateChange() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
// document.getElementById("results").innerHTML = xmlHttp.responseText;
// alert("The server replied with:" + xmlHttp.responseText);
}
}

}
</script>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表