﻿function createXMLHttp() {
	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	} else if(window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP");
	} 
	throw new Error("XMLHttp object could be created.");
}

function _sendRequest(url,func,isxml,ispost)
{
	var xhr=createXMLHttp();
	if(!ispost)ispost=null;
	xhr.open(ispost?"POST":"GET",url,true);
	if(func){
		xhr.onreadystatechange=function(){
			if(xhr.readyState==4){
				func(isxml&&xhr.responseXML?xhr.responseXML:xhr.responseText)
			}
		}
	}
	if(is_ie >=7 )
	{
		ispost = null;
	}
	xhr.send(ispost)
}

function ajaxRead(file,fun){
	var xmlObj = createXMLHttp();

	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			if (xmlObj.status ==200){
				obj = xmlObj.responseXML;
				eval(fun);
			}
			else{
				alert("读取文件出错,错误号为 [" + xmlObj.status  + "]");
			}
		}
	}
	xmlObj.open ('GET', file, true);
	xmlObj.send (null);
}