function GBMadAJAX() {
	var xml;
	var rs;
	var body = new Array();
	var self = this;
	var sending = false;
	var sto;
	//创建xml对象
	if (window.XMLHttpRequest) {
		xml = new XMLHttpRequest();//其他浏览器创建xmlhttp的控制控件
	} else {
		try {
			xml = new ActiveXObject("Microsoft.XMLHTTP");//windows IE浏览器下创建xmlhttp对象的控制控件
		} catch(e) {
		}
	}
	this.method = "GET";
	this.url = "?";
	this.async = true;
	this.to = 0;
	this.rsid = "";
	this.rbt = 0;
	this.rbody = "";
	this.Uninitialized = function() {};
	this.Loading = function() {};
	this.Loaded = function() {};
	this.Interactive = function() {};
	this.Completed = function() {};
	this.Error = function() {};
	this.Busy = function() {};
	this.TimeOut = function() {};
	this.Add = function(key, val) {
		body[body.length] = encodeURIComponent(key) + "=" + encodeURIComponent(val);
	}
	this.Open = function() {
		if (this.rsid) {//先判断创建对象的时候有没有制定该属性
			rs = document.getElementById(this.rsid);
			this.Uninitialized = function() {
				rs.innerHTML = "Uninitialized...";
				rs.innerHTML += "Your browser don't support for XmlHttpRequest.";
			}
			this.Loading = function() {
				rs.innerHTML = "Loading...";
			}
			this.Loaded = function() {
				rs.innerHTML = "Loaded...";
			}
			this.Interactive = function() {
				rs.innerHTML = "Interactive...";
			}
			this.Completed = function() {
				rs.innerHTML = "Completed...";
				rs.innerHTML = xml.responseText;// 会在指定的id标签里现实出服务器所返回的字符串。只返回字符串的数据
			}
			this.Error = function() {
				rs.innerHTML = "Completed...";
				rs.innerHTML += "Status: " + xml.status + " " + xml.statusText;
			}
			this.Busy = function() {
				rs.innerHTML = "Server too busy...Please wait or click the Refresh button.";
			}
			this.TimeOut = function() {
				rs.innerHTML = "Server time out...Please click the Refresh button.";
			}
		}
		if (xml) {//这个是肯定会执行的。因为xml已经在对象内创建了
			if (sending) {//sending默认是为false
				this.Busy();//调用ajax忙的函数
			} else {
				sending = true;//ajax正在执行。定义sending为真
				this.method = this.method.toUpperCase();//把方法名转为大写
				if (this.url.indexOf("?") > -1) {//都要随机的产生一个0.254587894524565= 连在url 后面。注意，还有一个等号
					this.url += "&" + Math.random() + "=";
				} else {
					this.url += "?" + Math.random() + "=";
				}
				if (this.method == "GET") {//这里还可以数组的方式进行提交请求。
					this.url += "&" + body.join("&")
				}
				xml.open(this.method, this.url, this.async);//调用了ajax对象的open方法
				if (this.async) {//这里比较重要。因为设置了状态处理函数。 当状态为4的时候则调用了。返回数据的函数
					xml.onreadystatechange = StateChange;//设置控制请求状态的回复函数
				}
				if (this.to) {//这里的to应该是代表该请求所运行的时间不超过5秒。如果超出5秒就停止发送请求
					sto = window.setTimeout(function() {Abort();}, this.to);
				}
				//--------------------------------------------------------------------------send才是真正想服务器发送请求。而前面只是在设置参数
				if (this.method == "GET") {//如果提交方法是GET。 则是send(null);  如果是post。则不是了
					xml.send("");
				} else {
					xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					xml.send(body.join("&"));
				}
				if (!this.async) {//这里没看懂 。。。。 难道默认不执行received函数吗？ 
					Received();
				}
			}
		} else {
			this.Uninitialized();
		}
	}
	function StateChange() {//不同的请求状态调用不同的函数
		switch (xml.readyState) {
			case 0://未初始化
				self.Uninitialized();
				break;
			case 1://下载中
				self.Loading();
				break;
			case 2://下载已完成
				self.Loaded();
				break;
			case 3://交互的。。交互状态是响应被部分接收时的状态----------------------------------------实际上从0到3都是调用的一个空函数
				self.Interactive();
				break;
			case 4://最后才调用了一个返回数据的函数
				Received();
				break;
		}
	}
	function Received() {
		if (sto) {
			window.clearTimeout(sto);
		}
		body = new Array();
		sending = false;
		if (xml.status == 200) {//http状态ok的时候返回200的时候=========================返回数据到rbody变量中。至于如何使用rbody变量就看completed函数了
			switch (self.rbt) {//返回的类型
				case 1://body格式
					self.rbody = xml.responseBody;
					break;
				case 2://按照xml文档形式返回
					self.rbody = xml.responseXML;
					break;
				case 3://流格式返回
					self.rbody = xml.responseStream;
					break;
				default://默认是按照字符串形式返回
					self.rbody = xml.responseText;
					break;
			}
			self.Completed();//再执行Completed()函数   =============================== 这样是为了真正的使用从服务器所返回的结果
		} else {
			self.Error();//默认error函数是个空函数。
		}
	}
	function Abort() {
		if (sending) {//如果sending为真
			xml.abort();//停止当前的请求
			body = new Array();//初始化body数组
			sending = false;//定义sending为false。因为已经停止当前的请求了
			self.TimeOut();
		}
	}
	/*@cc_on @*/
	/*@if (@_jscript_version < 5.5)
	function encodeURIComponent(str) {
		var s = new Array('%00', '%01', '%02', '%03', '%04', '%05', '%06', '%07', '%08', '%09', '%0A', '%0B', '%0C', '%0D', '%0E', '%0F', '%10', '%11', '%12', '%13', '%14', '%15', '%16', '%17', '%18', '%19', '%1A', '%1B', '%1C', '%1D', '%1E', '%1F', '%20', '!', '%22', '%23', '%24', '%25', '%26', "'", '(', ')', '*', '%2B', '%2C', '-', '.', '%2F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '%3A', '%3B', '%3C', '%3D', '%3E', '%3F', '%40', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '%5B', '%5C', '%5D', '%5E', '_', '%60', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '%7B', '%7C', '%7D', '~', '%7F');
		var r = new Array();
		var l = str.length;
		var i;
		var j = 0;
		var c;
		for (i = 0; i < l; i++) {
			c = str.charCodeAt(i);
			if (c < 128) {
				r[j++] = s[c];
			} else if (c < 2048) {
				r[j++] = "%" + ((c >> 6) + 192).toString(16).toUpperCase();
				r[j++] = "%" + ((c & 63) + 128).toString(16).toUpperCase();
			} else if (c < 65536) {
				r[j++] = "%" + ((c >> 12) + 224).toString(16).toUpperCase();
				r[j++] = "%" + (((c >> 6) & 63) + 128).toString(16).toUpperCase();
				r[j++] = "%" + ((c & 63) + 128).toString(16).toUpperCase();
			} else if (c < 2097152) {
				r[j++] = "%" + ((c >> 18) + 240).toString(16).toUpperCase();
				r[j++] = "%" + (((c >> 12) & 63) + 128).toString(16).toUpperCase();
				r[j++] = "%" + (((c >> 6) & 63) + 128).toString(16).toUpperCase();
				r[j++] = "%" + ((c & 63) + 128).toString(16).toUpperCase();
			}
		}
		return r.join("");
	}
	@end @*/
}