原文地址:http://cache.baiducontent.com/c?m=9d78d513d9d437a94f9993697b15c012124381132ba6da020cd7843894732a40506793f1787c0705a39f3a2143b8482cfdf04165367360e0da8ad5169cec85295fce707e360b873105a31eb8ba4032c050872aecb869e0ad804284d8d8c4de2444bc57120a87e4cc1a5e1b9029b65626e2d58455501a55aded4733a81c2075882337ed1ae4a32f6e078af4&p=8b2a9702909706ff57ed977b5b648c&newp=82769a479e8903ff57ed977b7f64c1231610db2151dcd55d3596&user=baidu&fm=sc&query=%D4%F5%D1%F9%C8%A1%B5%C3xmlHttp%2EresponseText%B5%C4%B7%B5%BB%D8%D6%B5&qid=e3a54b05000055ba&p1=31
function httpGET(url,sync,fun){
var xhr = window.XMLHttpRequest? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
if(typeof sync === 'function') {
fun = sync;sync =true;
}else if(typeof sync === 'undefined'){
sync =true;
}
xhr.onreadystatechange=function(){
if(xhr.readyState==4 && xhr.status==200){
fun.call(this,xhr.responseText);
}
}
xhr.open("GET",url,sync);
xhr.send();
}
//调用方法
httpGET("/index.php",function(data){
alert(data);
});