[英]Access denied in ajax call with IE
I'm getting access denied when sending this request to the server through ajax. 通过ajax发送此请求到服务器时,我的访问被拒绝。 I have also done with
XDomainRequest
for the IE browsers but I am still getting the access denied problem. 我也已经为IE浏览器完成了
XDomainRequest
,但是我仍然遇到访问被拒绝的问题。 When I run this with my local address it is working but it is not working when I use another address. 当我使用本地地址运行它时,它正在工作,但是当我使用另一个地址时,它却不工作。
jQuery.support.cors = true;
$.ajax({
type:callType,
url:url,
data:requestBody,
crossDomain:true,
success:function (returnData, status, xhr) {
alert("getDataFromJQuery success");
alert(url);
callback(returnData.response ? returnData.response : returnData);
},
error:function (jqXHR, exception) {
alert("getDataFromJQuery error"+JSON.stringify(jqXHR));
if (errcallback) {
errcallback(jqXHR, exception);
} else {
alert("exception in making [" + url + "] :[" + exception + "]");
}
},
timeout:1200000,
dataType:dataType,
});
As per @FritsvanCampen, the place you're asking for data from needs to allow that. 根据@FritsvanCampen的要求,您要从中获取数据的地方必须允许这样做。 If you control that location, make sure the server sets a
Access-Control-Allow-Origin
header value that allows requests by the domain your requesting page is on. 如果控制该位置,请确保服务器设置一个
Access-Control-Allow-Origin
标头值,该值允许按请求页面所在的域进行请求。
See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS for more information that you want to read (but should read anyway =) 请参阅https://developer.mozilla.org/zh-CN/docs/HTTP/Access_control_CORS ,以获取要阅读的更多信息(但无论如何应阅读=)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.