ajax中获取xmlHttp对象方法

 xmlhttp对象的获取与ie浏览器的版本有很大的关系,我们不能ActiveXObject( " Microsoft.XMLHTTP " )一个对象,这样在大多数情况下是没有问题的,但是在有些ie中,这样new是不行的,所有我们获取xmlhttp对象是不能这样的。
ExpandedBlockStart.gif ContractedBlock.gif function XMLHTTP()  dot.gif {
InBlock.gif    var xmlHTTP;
InBlock.gif    var msxmlhttp 
= new Array(
InBlock.gif    
'Msxml2.XMLHTTP.5.0',
InBlock.gif    
'Msxml2.XMLHTTP.4.0',
InBlock.gif    
'Msxml2.XMLHTTP.3.0',
InBlock.gif    
'Msxml2.XMLHTTP',
InBlock.gif    
'Microsoft.XMLHTTP');
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for (var i = 0; i < msxmlhttp.length; i++dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
try dot.gif{
InBlock.gif            xmlHTTP 
= new ActiveXObject(msxmlhttp[i]);
ExpandedSubBlockStart.gifContractedSubBlock.gif        }
 catch (e) dot.gif{
InBlock.gif            xmlHTTP 
= null;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
if(!xmlHTTP && typeof XMLHttpRequest != "undefined")
InBlock.gif    xmlHTTP 
= new XMLHttpRequest();
InBlock.gif    
return xmlHTTP;
ExpandedBlockEnd.gif}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值