I am an absolute beginner to jQuery and json, and I am trying to parse a json object using jquery. The json object is
{"interested":1,"like":3,"dislike":2}
The code I am using to parse the json object is
$.getJSON( "get_reviews.php?mid=x&uid=0",
function (data)
{
console.log("parsing");
Interested = data.interested;
Dislike = data.dislike;
Like = data.like;
}
The error I'm getting is
XMLHttpRequest cannot load http://www.********.***/get_reviews.php?mid=x&uid=0. Origin http://********.*** is not allowed by Access-Control-Allow-Origin.
Anyone knows where I'm going wrong? I've tried fixing it in several ways (using different examples for AJAX requests).
----Edit---- Despite not accessing any cross-domain file, I took the suggestion from this question:
XMLHttpRequest cannot load an URL with jQuery
And added "&callback=?" to my code url, which got rid of the error mentioned above but now gives another error
Uncaught SyntaxError: Unexpected token :
Since there's only one line, it seems to refer to the colon in the json object, which seems extremely odd. Any idea why this might be happening.
PS: I also took user1105704's suggestion below with the ajax method (I'd tried this before) except making the dataType "jsonp", and it reproduces the error regarding the Unexpected token