AJAX技术的核心

//创建一个XMLHttpRequest对象 ,利用此对象与服务器进行通信 是AJAX技术的核心
   
/**
 * 获取XmlHttpRequest对象
 */
function getXMLHttpRequest() {
    var xmlHttpReq=null;
    if (window.XMLHttpRequest) {//Mozilla 浏览器
        xmlHttpReq = new XMLHttpRequest();
    }else {
        if (window.ActiveXObject) {//IE 浏览器
            try {
                xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                try {//IE 浏览器
                    xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e) {
                }
            }
        }
    }
    return xmlHttpReq;
}