//創建對象
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
//前台界面事件調用的函數
function checkName(){
createXMLHttpRequest();
XMLHttp.onreadystatechange = handleStateChange;
var sql = "UserReg.ASPx?";
XMLHttp.open("GET",sql,true);
XMLHttp.send(null);
}
//和服務器交互期間執行的函數
function handleStateChange(){
if(XMLHttp.readyState == 4){
if(XMLHttp.status == 200){
document.getElementById("divx").innerHtml = XMLHttp.responseText;
}
}
}
<script>