function createXMLHttpRequest(){//创建XMLHttpRequest对象
if(window.ActiveXObject){//IE
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch(e){
return;
}
}else if(window.XMLHttpRequest){//Mozilla,firefox
try {
return new XMLHttpRequest();
} catch(e){
return;
}
}
}
function getreNews(Value){//主调函数
var xmlHttp=createXMLHttpRequest();
var url = "ajaxSend.php?title="+Value+"&mt="+Math.random(300000);
if (Value==""){
return false ;
}
if (xmlHttp){
callback = getReadyStateHandler(xmlHttp);
xmlHttp.onreadystatechange = callback;
xmlHttp.open("GET", url,true);
xmlHttp.send(null);
}
}
function getReadyStateHandler(xmlHttp){//服务器返回后处理函数
return function (){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
if (xmlHttp.responseText){
document.getElementById("apDiv1").style.display='block';
document.getElementById("apDiv1").innerHTML=xmlHttp.responseText;
}else{
document.getElementById("apDiv1").innerHTML="<li>对不起,未找到相对应楼盘!</li>";
}
}
}
}
}
|