AJAX请求很简单

var xmlHttp;
    function createXMLHttpRequest(){
        if(window.ActiveXObject){
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }else if(window.XMLHttpRequest){
            xmlHttp = new XMLHttpRequest();
        }
    var url;
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=showResult;
    xmlHttp.send(null);
    }
function showResult(){
   if(xmlHttp.readyState==4){
       if(xmlHttp.status==200){
			var texts=xmlHttp.responseText;
			}
        }
   }
}		


你可能感兴趣的:(ajax请求)