I'm getting access denied when sending this request to the server through ajax. I have also done with XDomainRequest
for the IE browsers but I am still getting the access denied problem. 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. 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.
See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS for more information that you want to read (but should read anyway =)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.