console
var xmlhttp = null;
function createXMLHttpRequest(){
if(window.ActiveXObject){ // IE浏览器
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){ // 非IE浏览器
xmlhttp = new XMLHttpRequest();
}
}
function startRequest(){
createXMLHttpRequest();
var url = "index.php"; // 要使用的服务器URL
xmlhttp.open("get",url,true); // 使用open()方法发送一个异步请求
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
alert(xmlhttp.responseText);
}
}
xmlhttp.send(null);
<button name="button" onclick="startRequest();" />获取服务端文本</button>