使用IE8和IE9跨域ajax响应 [英] Cross domain ajax response with IE8 and IE9

查看:100
本文介绍了使用IE8和IE9跨域ajax响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



im有跨域调用问题ajax调用

与IE8和IE9



我的下面的代码在Firefox,Chrome,IE 10中工作得很好

但不能在IE8和IE9中工作



i花了我很多时间在谷歌搜索但没有成功。



我的代码是:



hi all,

i m having a problem with cross domain ajax call
with IE8 and IE9

My below code working fine in Firefox, chrome, IE 10 too
but not working in IE8 and IE9

i spend lot of my time in searching on google but not succeed.

my code is:

$.ajax({
                type: "GET",
                crossDomain: true,
                url: 'MyUrl',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data1) {
			alert(data1);
                },
                error: function (response, textStatus, errorThrown) {
                    alert('not OK ' + response.responseText);
                    alert('not OK ' + textStatus.responseText);
                    alert('not OK ' + errorThrown);
                }
            });





i使用下面的js但仍然无法工作



< script type =text / javascriptsrc =http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.1/jquery.xdomainrequest.min.js >< / script>



参考:https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest



请帮帮我们



i used this below js also but still not working

<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.1/jquery.xdomainrequest.min.js"></script>

reference : https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest

please help me guys

推荐答案

.ajax({
type:GET,
crossDomain:true,
url:'MyUrl',
contentType:application / json; charset = utf-8,
dataType:json,
成功:函数(data1){
alert(data1);
},
错误:函数(response,textStatus,errorThrown){
alert('not OK'+ response.responseText);
alert('not OK'+ textStatus.responseText);
alert('not OK' + errorThrown);
}
});
.ajax({ type: "GET", crossDomain: true, url: 'MyUrl', contentType: "application/json; charset=utf-8", dataType: "json", success: function (data1) { alert(data1); }, error: function (response, textStatus, errorThrown) { alert('not OK ' + response.responseText); alert('not OK ' + textStatus.responseText); alert('not OK ' + errorThrown); } });





i在js下使用这个但是仍然没有工作



< script type =text / javascriptsrc =http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.1 /jquery.xdomainrequest.min.js\"></script>



参考:https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest



请帮帮我们



i used this below js also but still not working

<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.1/jquery.xdomainrequest.min.js"></script>

reference : https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest

please help me guys


大家好我找到了答案。

IE9和更低的版本IE不支持ort httpXMLRequest并解决这个问题

我们必须使用XDomainRequest拨打电话。

答案如下。



Hello guys i found the answer.
IE9 and lower verstion of IE does not support httpXMLRequest and to solve this problem
we have to make a call by using XDomainRequest.
The answer is below.

if (


.browser.msie&& window.XDomainRequest){
if (window.XDomainRequest){
var xdr = new XDomainRequest();
var query = ' MyUrl';
if (xdr){
xdr.onload = function(){
alert(xdr.responseText);
}
xdr.onerror = function(){ / * 此处的错误处理* / }
xdr.open(' GET',query);
xdr.send();
}
}
}
其他 {
.browser.msie && window.XDomainRequest) { if (window.XDomainRequest) { var xdr = new XDomainRequest(); var query = 'MyUrl'; if (xdr) { xdr.onload = function () { alert(xdr.responseText); } xdr.onerror = function () { /* error handling here */ } xdr.open('GET', query); xdr.send(); } } } else {


这篇关于使用IE8和IE9跨域ajax响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆