Ajax通用模板實現代碼_AJAX教程
推薦:Ajax創建XMLHttp對象的完美兼容性代碼Ajax創建XMLHttp對象的完美兼容性代碼,需要的朋友可以參考下。
復制代碼 代碼如下:www.ghpqjb.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>
分享:看圖理解 普通交互方式和Ajax交互方式區別看圖理解 普通交互方式和Ajax交互方式區別,需要的朋友可以參考下。
相關AJAX教程:
- 相關鏈接:
- 教程說明:
AJAX教程-Ajax通用模板實現代碼
。