Delmon Young
Delmon Young

Reputation: 2053

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!

Upvotes: 1

Views: 3331

Answers (2)

Mark Schultheiss
Mark Schultheiss

Reputation: 34178

Try it this way:

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

Upvotes: 1

ddavison
ddavison

Reputation: 29032

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

Upvotes: 1

Related Questions