jQuery跨域请求失败“拒绝访问”在IE中 [英] jQuery cross domain request failing "Access Denied" in IE

查看:111
本文介绍了jQuery跨域请求失败“拒绝访问”在IE中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello There,

My Ajax cross domain request is failing in IE 11 with "Access denied". I have read through several posts regarding this topic, and done below changes but getting same issue.

1)  Call is async=false, dataType='json' and crossDomain, cache is false. 
    These are the prerequisites I have found.
2)  Works in latest Firefox and Chrome.
    jQuery.support.cors is true
  
Why is this failing with Access denied? Any idea? 

I have tried with JSONP and here i am not getting "Acces Denied" error. But problem is, i can able to get the result into success function and the same passing to global variable. when call the global parameter outside of the success function, there it is coming "Undefined". 

 I have read through several posts regarding this issue also. FYR, was followed the below link.

<a href="http://stackoverflow.com/questions/26668290/jquery-javascript-store-ajax-jsonp-response-into-variables">Link</a>[<a href="http://stackoverflow.com/questions/26668290/jquery-javascript-store-ajax-jsonp-response-into-variables" target="_blank" title="New Window">^</a>]

Can any one please help me.

Thanks in advance

Regards,
K N R

推荐答案

您需要在webconfig文件中允许跨站点起源。这只需使用webconfig中的以下标记即可完成。您可以将*替换为您发出请求的域名(来源)。



还要确保

crossDomain:是的,

你的ajax请求。



You will need to allow cross site origins in your webconfig file. This is simply done using the following tags in your webconfig. You can replace the "*" with the domain you are making the request from (the origin).

also make sure
crossDomain: true,
on your ajax request.

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <!--
            Allow Web API to be called from a different domain.
            
            -->
            <add name="Access-Control-Allow-Origin" value="*" />
        </customHeaders>
    </httpProtocol>
</system.webServer>


这篇关于jQuery跨域请求失败“拒绝访问”在IE中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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