var XmlHttp = false;
var RepText = "";
var RsFun   = null;  //结果处理函数
try 
{  XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) 
{ try { 
  XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  } //IE浏览器的创建方式
  catch (e2) {xmlHttp = false;  }
}
if (!XmlHttp && typeof XMLHttpRequest != 'undefined') 
{ XmlHttp = new XMLHttpRequest();//如果在IE浏览器创建失败则按非IE方式创建    
  if(XmlHttp.overrideMimeType)
  {  XmlHttp.overrideMimeType("text/xml");      
  }
}      

//发送函数    
function AjaxRequest(myUrl, pData)
{  
  XmlHttp.open("POST", myUrl, true);
  XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
  XmlHttp.setRequestHeader("Connection", "close"); 
  XmlHttp.onreadystatechange=AjaxCallBack;    
  XmlHttp.send(pData);  
}
//回调函数
function AjaxCallBack()
{  if (XmlHttp.readyState==4 || XmlHttp.readyState=='complete')
  {  
    RepText = XmlHttp.responseText;  
    if(typeof(RsFun) != "undefined") {
      RsFun(RepText);      
    }
  }    
}

//入口函数(基本URL，URL参数，POST数据，回调处理函数)
function AjaxSend(baseurl, uData, pData, RecFun)
{
  RsFun = RecFun;    
  uData = encodeURI(uData);
  var Rand  = Math.random();
  var myUrl = baseurl+"?"+uData+"&r="+Rand;
  AjaxRequest(myUrl, pData);
}

