function ajaxGet(url,callback){
var xhr = null;
if( window.XMLHttpRequest){
xhr = new XMLHttpRequest( );
}else{
xhr = new ActiveXobject("Microsoft.XMLHTTP");
}
xhr.open ("GET||POST","url");//url指路径
xhr.send();//发送请求
xhr.setRequestHeader("If-Modified-Since","0");//解决缓存问题
xhr.onreadystatechange = function(){
if(xhr.readyState == 4&&xhr.status == 200){
callback(xhr.responseText);//因为返回的结果到下一个功能中,所以通过参数传递将服务器的返回结果传回
}
}
}
//注:结果存在于属性responseText