Ajax中怎么实现一个通用模板

2023-10-28

Ajax中怎么实现一个通用模板,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

代码如下:

<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中怎么实现一个通用模板.doc》

下载本文的Word格式文档,以方便收藏与打印。