function creatajax(){
VAR ajax=null;
if (window.
XMLHtt
PRequest){
//对于Mozilla、Netsca
PE、Safari等浏览器,创建X
MLHttpRequest对象
ajax = new XMLHttpRequest();
if (ajax.
overrideMimeType){
//如果
服务器响应的header不是text/xml,可以调用其它方法修改该header
ajax.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject){
// 对于
internet E
xplorer浏览器,创建XMLHttpRequest
try{
ajax = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e){
try{
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){}
}
}
return ajax;
}
把上面代码放到js文件中 。以方便以后直接调用