首页 > 代码库 > AJAX格式

AJAX格式

var xmlHttp;
function getXmlHttp(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("MICROSOFT.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}

function sendParam(url){
getXmlHttp();

xmlHttp.open("GET","check.php?user="+url,true);
// setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = getTxt;
xmlHttp.send(null);
}
function getTxt(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
var sp = document.getElementById("tishi");
sp.innerHTML = xmlHttp.responseText;
}
}
}