ajax兼容ie浏览器 360兼容模式

1.

<script>$(document).ready(function() {$.ajax({url: "网页链接",dataType: "text",async: true,type: 'GET',cache: false,crossDomain: true == !(document.all),success: function(txt) {alert(txt);}});});</script>

重要的是:crossDomain: true == !(document.all)这句代码


2.查看下ie浏览器是否允许ajax访问,操作地址:http://blog.csdn.net/liu4071325/article/details/62046255 

2.1 ajax兼容360兼容模式

<meta http-equiv="X-UA-Compatible" content="IE=9;IE=8;IE=7;IE=EDGE">



3.

$.ajax({
            async: true,  
            type : "GET", 

//encodeURI中文转字符
            url: encodeURI("http://my.ganjiangps.com/ui/imagetextsetting/getbyitiname.action?pcterminal=1&itino=58&title=联系我们"),
            dataType:'html',
            crossDomain: true == !(document.all),
            success: function(d) {
            var s = JSON.parse(d);
                   
            $(".content").html(s.list[0].content);
        },
            complete: function(XMLHttpRequest, textStatus) {
                console.log("complete")
            },
            error: function(){alert("error")}
        });



4.封装ajax

//javascript Object: ajax Object
//Created By RexLee
function Ajax(url,data){
     this .url=url;
     this .data=data;
     this .browser=( function (){&nbsp;&nbsp;
         if (navigator.userAgent.indexOf( "MSIE" )>0) {&nbsp;&nbsp;
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "MSIE" ; //IE浏览器
         } else {
             return "other" ; //其他
     }})();
};
Ajax.prototype={
     get: function (){
         var result;
         var xmlhttp;
         if ( this .browser== 'MSIE' ){
             try {
                 xmlhttp= new ActiveXObject( 'microsoft.xmlhttp' );
                 } catch (e){
                     xmlhttp= new ActiveXObject( 'msxml2.xmlhttp' );
                     }
             } else {
                 xmlhttp= new XMLHttpRequest();
             };
         xmlhttp.onreadystatechange= function (){
             result = xmlhttp.responseText; //闭包,不能采用this.属性
         };
         xmlhttp.open( 'GET' , this .url+ '?' + this .data, false ); //true无法抓取数据,why?
         xmlhttp.send( null );
         return result;
     },
     post: function (){
         var result;
         var xmlhttp;
         if ( this .browser== 'MSIE' ){
             xmlhttp= new ActiveXObject( 'microsoft.xmlhttp' );
             } else {
                 xmlhttp= new XMLHttpRequest();
             };
         xmlhttp.onreadystatechange= function (){
             result = xmlhttp.responseText; //闭包,不能采用this.属性
         };
         xmlhttp.open( 'POST' , this .url, false ); //需设为false,否则无法抓取responseText
         xmlhttp.setRequestHeader( "Content-Type" , "application/x-www-form-urlencoded" ); //POST中,这句必须
         xmlhttp.send( this .data);
         return result;
     }
};
  
//var a=new ajax('opp2.js','');
//alert('by GET\\n'+a.get())
//alert('by POST\\n'+a.post());
///
  
  
  
window.onload= function (){
document.getElementById( "btn" ).onclick= function (){
     var p=document.getElementById( "t" ).value;
     var a= new Ajax( "phpOOP/getPage.php" , "page=" +p);
     document.getElementById( "box" ).innerHTML=a.get();
     };
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值