/**
 * ajax请求调用函数
 * url － 请求url地址
 * query － 请求带的变量 get方式前面要带& 或者 ?
 * resfun － 外部定义的回馈函数
 * method － 提交方法 GET POST
 * bool － 请求是否为异步方式 true false
 */
function ajaxRequest(url,query,resfun,method,bool,type) {
	//检测变量
	if(url == undefined) return false;
	if(query == undefined) query = '';
	if(resfun == undefined) resfun = '';
	if(method == undefined) method = 'POST';
	if(bool == undefined) bool = true;
	//alert("url=" + url+" , query="+query+" , method="+method+" , bool="+bool);
	//定义变量
	var xmlHttp;
	//创建XMLHttpRequest对象的一个实例
	if (window.ActiveXObject) xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) xmlHttp = new XMLHttpRequest();
	//回调函数，显示返回的数据－－－responseText,还可以是responseXML
	xmlHttp.onreadystatechange = function () {
		//alert("readystate="+xmlHttp.readyState);
		//alert("status="+xmlHttp.status);
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				//alert(xmlHttp.responseText);
			 // var ret = type=='XML' ? xmlHttp.responseXML : xmlHttp.responseText;	
				if(resfun != '') resfun(xmlHttp);
				//反馈函数样式  --- 一般会写在外面  独立出去
//				function resfun(result) {
//					//如果使用json编辑了返回的，下面反解析成object
//					var response = eval('('+result+')');
//					............
//				}
			}
		}
	}
	//根据不同的方法进行不同的提交操作
	if(method == 'GET') {
		xmlHttp.open(method,url+query,bool);
		xmlHttp.send(null);
	} else if(method == 'POST') {
		xmlHttp.open(method,url,bool);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
		xmlHttp.send(query);
	}
}
