日期:2014-05-17 浏览次数:20686 次
<script>
//Ajax
var xmlHttp;
function createXMLHttpRequest() {
if(window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
createXMLHttpRequest();
//API接口
url = "xxx.php?param="+param+"&ran="+Math.random();
method = "GET";
xmlHttp.open(method,url,true);
xmlHttp.onreadystatechange = show;
xmlHttp.send(null);
}
function show(){
if (xmlHttp.readyState == 4){
if (xmlHttp.status == 200){
var text = xmlHttp.responseText;
alert("xml-->>"+text);
//document.getElementById("s2").innerHTML = text;
}else {
alert("response error code:"+xmlHttp.status);
}
}
}
</script>
------解决方案--------------------