var xmlHttp = false;

/*
	功能: 以支持多种浏览器的方式创建 XMLHttpRequest 对象
*/
function createXmlHttp(){

	try{
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e1){
		try{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e2){
			try{
				xmlHttp = new XMLHttpRequest();
			}catch(e3){
				xmlHttp = false;
				alert("无法创建XMLHttpRequest对象");
			}
		}
	}
	
}


/*
	功能: 向服务器发送请求
	参数: url
*/
function callServer( url ){
	
	xmlHttp.open("GET", url, true);
	xmlHttp.setRequestHeader("Cache-Control", "no-cache");
	//xmlHttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
	
}


/*
	功能: 向服务器发送请求
*/
function sendTo(){
	
	xmlHttp.send();
	
}


/*
	功能: 更新页面的指定部分
	参数: url, 要更新的元素ID(即标记的ID)
	返回值: 无
*/
function updateItem( url, itemId ){
	
	callServer( url );
	xmlHttp.onreadystatechange = function (){
		if( xmlHttp.readyState == 4 && xmlHttp.status == 200 ){
			var response = xmlHttp.responseText;
			document.getElementById( itemId ).innerHTML = response;
		}
	}
	sendTo();
	
}


createXmlHttp();
