您的位置:首页 > 编程语言

Ajax通用模板实现代码

2011-12-19 00:00 399 查看
<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: