
function $(obj){
	return document.getElementById(obj);
}

function createXMLHttp(){
	if(typeof XMLHttpRequest != "undefined"){
		return new XMLHttpRequest();
	}else if(window.ActiveXObject){
		var aVersions = ["MSXML2.XMLHttp.5.0",
		"MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
		"MSXML2.XMLHttp","Microsoft.XMLHttp"];
		for(var i = 0;i < aVersions.length; i++){
			try{
				var oXmlHttp = new ActiveXObject(aVersions[i]);
				return oXmlHttp;
			}catch(oError){
				//Do nothing
			}
		}
	}
	throw new Error("XMLHttp 对象不能创建.");
}

function sendRequest(sendURL,sendData,successFunc,failureFunc){
	//var timeOut;
	try{
		var oXmlHttp = createXMLHttp();
		oXmlHttp.open("post",sendURL,true);
		oXmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		oXmlHttp.send(sendData);
		oXmlHttp.onreadystatechange = function(){
			if(	oXmlHttp.readyState == 4){			
				if(	oXmlHttp.status == 200){						
						if(successFunc != null){						
						successFunc(oXmlHttp.responseText);
					}
				}else{
						if(failureFunc != null){
						failureFunc("发生了以下错误: " + oXmlHttp.statusText);
					}
				}
			}
		}
		//oXmlHttp.send(sendData);
		//timeOut = setTimeout(function (){oXmlHttp.abort();},10000);//10秒后还没收到数据,则取消当前请求
	}catch(e){
		alert("出现了以下错误:" + e.message);
	}
}