Ajax通用模板实现代码
Ajax通用模板实现代码
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:varxmlHttp;functioncreatXMLHttpRequest(){if(window.ActiveXObj...

复制代码 代码如下:

<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>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新AJAX相关学习
热门AJAX相关学习
编程开发子分类