AJAX

[size=x-small; font-family: courier new,courier]
	var req;    

	function createXmlHttpRequest()    
	{    
		 if (window.XMLHttpRequest) {    
			 req = new XMLHttpRequest();    
		 }else if (window.ActiveXObject) {    
			 req = new ActiveXObject("Microsoft.XMLHTTP");    
		 }    
	}
	
	function sendRequest(url){
		if(req){
			req.open("GET", url, true);    
			req.onreadystatechange = callback;
			req.send(null);            
		 }else{
		 	createXmlHttpRequest();
		 }
	}
	   
	function callback(){
		if (req.readyState == 4){
			if (req.status == 200){
					 parseMessage();
			}
		}    
		else   
		{    
			document.getElementById("check_username").innerHTML = "正在验证用户名....";    
		}    
	}    
	   
	function parseMessage() {    
		var xmlDoc = req.responseXML.documentElement;    
		var node = xmlDoc.getElementsByTagName('info');    
		document.getElementById('check_username').innerHTML = node[0].firstChild.nodeValue;    
	}
[/size]

你可能感兴趣的:(Ajax,Microsoft)