/** 
 * AJAX类
 * @author tangh
 */
function AJAXRequest() {
	var xmlObj = false;
	var CBfunc,ObjSelf;
	ObjSelf=this;
	
	if (window.XMLHttpRequest) {       // 在Mozilla, Safari,...非Microsoft浏览器中创建XMLHttpRequest对象
	    xmlObj = new XMLHttpRequest();
	    if (xmlObj.overrideMimeType) {
	        xmlObj.overrideMimeType('text/xml;charset=gbk');
	    }
	} else if (window.ActiveXObject) { // IE,通过MS ActiveX创建XMLHttpRequest
	    try {
	    	// 尝试按新版IE方法创建
	        xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	        try {
	        	// 创建请求的ActiveX对象失败,尝试按老版IE方法创建
	            xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {
	        	xmlObj=false;	
	        }
	    }
	}
	
	if (!xmlObj) return false;
	this.method="GET";        //请求方法，字符串，POST或者GET，默认为GET
	this.url;                 //请求URL，字符串，默认为空
	this.async=true;          //是否异步，true为异步，false为同步，默认为true
	this.content="";          //请求的内容，如果请求方法为POST需要设定此属性，默认为空
	this.callback=function(cbobj) {return;} //回调函数，即返回响应内容时调用的函数，默认为直接返回，回调函数有一个参数为XMLHttpRequest对象，即定义回调函数时要这样：function mycallback(xmlobj)
	this.send=function() {    //发送请求，无参数
		if(!this.method||!this.url||!this.async) return false;
		xmlObj.open (this.method, this.url, this.async);
		if(this.method=="POST"){
			 xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); //POST方法,指示请求体包含form数据
		}else{
			xmlObj.setRequestHeader("Content-Type", "text/html; charset=gbk");
		}
		xmlObj.onreadystatechange=function() {
			//alert("ready:"+xmlObj.readyState);
			if(xmlObj.readyState==4) {                //如果请求的状态是“完成”
				//alert("status:"+xmlObj.status);
				if(xmlObj.status==200) {              //检查是否成功接收了服务器响应
					ObjSelf.callback(xmlObj);
				}
			}
		}
		if(this.method=="POST") xmlObj.send(this.content);
		else xmlObj.send(null); //GET方法不用发送
	}
}