js xmlHttpRequest

var xhr =window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
if(xhr){
   xhr.onreadystatechange = function(){
       if (this.readyState == 4 && this.status == 200){
           //对返回数据的处理,下例为json类型
           var objJson = eval("(" + this.responseText + ")");
           for( i = 0; i < objJson.geoList.length; i++) {
               var item= objJson.geoList[i];
           }
                  
       }
  };
  var urlStr = "url?paras";
  xhr.open("GET", urlStr);
  xhr.send();
}

你可能感兴趣的:(XMLhttpREquest)