简体   繁体   中英

getJSON access is denied in IE

I'm using jquery to process the json on another domain. I'm using json2.js and testing this in IE9 and IE10 When I run this locally it works fine and sends the json successfully. However when I put this on another domain I get an "access is denied error" in IE.

Here is the json that I'm sending.

$.getJSON("http://somedomain.com/send?callback=?", {"name":name,"user":user},null);

Another strange occurance is that when I put this on a server any object that I pass json.stringify(obj); in the console returns "Access is denied". But if I pass console.log(obj); it returns the object successfully. But if I run the file locally I successfully return the json from json.stringify(obj);

I'm really really stumped on this any help or advice is greatly appreciated.

Thanks!

Sounds like a cross-domain-request issue.

You are unable to use getJSON() to fetch data from another site due to browser policies.

Check out this question for a workaround

Try it this way:

$.getJSON('http://somedomain.com/send?callback=?','name='+name'&user='+user,function(response){
    alert('response is ' + reponse);
});

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM