//建立一個XMLHttpRequest對象 ,利用此對象與伺服器進行通信 是AJAX技術的核心
/
function ajaxFunction(){
var xmlHttp;
try{ // Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{// Internet Explorer
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return xmlHttp;
}
/
function getXMLHttpRequest(){
var xmlHttpReq=null;
if (window.ActiveXObject) {//IE浏覽器建立XMLHttpRequest對象
xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
}else if(window.XMLHttpRequest){
xmlHttpReq = new XMLHttpRequest();
}
return xmlHttpReq;
}
/
/**
* 擷取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;
}