首页 > 代码库 > ajax 异步请求

ajax 异步请求

<script type="text/javascript" >	var http_request = false;	function send_request(url){		http_request = false;		if(window.XMLHttpRequest){	//Mozilla浏览器			http_request = new  XMLHttpRequest();			if(http_request.overrideMimeType){				http_request.overrideMimeType("text/xml");				}		}else if(window.ActiveXObject){			try{				http_request = new ActiveXObject("Msxml2.XMLHTTP");			}catch(e){				try{					http_request = new ActiveXObject("Microsoft.XMLHTTP");					}catch(e){									}			}		}				if(!http_request){			window.alert("不能创建XMLHttpRequest对象实例");			return false;			}				http_request.onreadystatechange = processRequest;		http_request.open("GET",url,true);		http_request.send(null);				}		//处理返回信息的函数	function  processRequest(){		if(http_request.readyState == 4){			if(http_request.status == 200){				alert(http_request.responseText);				}else{				alert("你请求的页面有异常");				}			}	}	</script>