/**//* 创建XMLHttpRequest的第一种方法
try{
searchReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e){
try{
searchReq = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(e){
try{
searchReq = new XMLHttpRequest();
}
catch(e)
{}
}
}
*/
//创建XMLHttpRequest的第二种方法
function createReq(){
var httpReq;
if(window.XMLHttpRequest){
httpReq = new XMLHttpRequest();
if(httpReq.overrideMimeType){
httpReq.overrideMimeType('text/xml');
}
}
else if(window.ActiveXObject){
try{
httpReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e){
try{
httpReq = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(e){
}
}
}
return httpReq;
}
ajax 之XMLHttpRequest两种创建方法
最新推荐文章于 2024-08-07 23:30:48 发布