xmlhttp.responseText 取值不到,回调函数最重要
function getDataByAjax(requestType,url){
var xmlhttp = createXMLHTTP();
if(window.XMLHttpRequest){
xmlhttp=new window.XMLHttpRequest();
//IE7.0,IE8.0,FireFox,Mozilla,Safari,Opera
xmlhttp = new XMLHttpRequest();
if(xmlhttp.overrideMineType){
xmlhttp.overrideMineType("text/xml");
}
}else if(window.ActiveXObject){
xmlhttp=new ActiveXObject(getXmlHttpPrefix()+".XmlHttp");
}
var xmlHead="<?xml version="1.0" encoding="GBK"?>";
if(url.indexOf("?")>0)
url+="&randomCode="+Math.round(Math.random()*9999999);
else
url+="?randomCode="+Math.round(Math.random()*9999999);
xmlhttp.open(requestType, url, false); //同步方式进行
xmlhttp.send(null);
if(xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
returnHtml=xmlhttp.responseText;
}else{
alert("您所请求的页面有误...");
}
}
return returnHtml;
}