抑郁症健康,内容丰富有趣,生活中的好帮手!
抑郁症健康 > ajax兼容ie浏览器 360兼容模式

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

时间:2021-11-27 07:21:18

相关推荐

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访问,操作地址:/liu4071325/article/details/62046255

2.1ajax兼容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("/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 RexLeefunctionAjax(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(){varresult;varxmlhttp;if(this.browser=='MSIE'){try{xmlhttp=newActiveXObject('microsoft.xmlhttp');}catch(e){xmlhttp=newActiveXObject('msxml2.xmlhttp');}}else{xmlhttp=newXMLHttpRequest();};xmlhttp.onreadystatechange=function(){result = xmlhttp.responseText;//闭包,不能采用this.属性};xmlhttp.open('GET',this.url+'?'+this.data,false);//true无法抓取数据,why?xmlhttp.send(null);returnresult;},post:function(){varresult;varxmlhttp;if(this.browser=='MSIE'){xmlhttp=newActiveXObject('microsoft.xmlhttp');}else{xmlhttp=newXMLHttpRequest();};xmlhttp.onreadystatechange=function(){result = xmlhttp.responseText;//闭包,不能采用this.属性};xmlhttp.open('POST',this.url,false);//需设为false,否则无法抓取responseTextxmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//POST中,这句必须xmlhttp.send(this.data);returnresult;}};//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(){varp=document.getElementById("t").value;vara=newAjax("phpOOP/getPage.php","page="+p);document.getElementById("box").innerHTML=a.get();};}

如果觉得《ajax兼容ie浏览器 360兼容模式》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。