Reputation: 1876
I've seen this question asked several times, but the solutions aren't working. At this link, there's a nameless JSON object. I'm trying to get access to the data in the object. This is what I've tried so far:
$.getJSON is returning different errors. I read that adding "&callback=?" to the url would stop the "Access-Control-Allow-Origin" error, which worked, but then I ran into the "Unexpected token :" error. The JSON data looks correct to me, though.
I also tried doing this:
<!DOCTYPE html>
<html>
<head>
<script src="jquery-latest.min.js"
type="text/javascript"></script>
</head>
<body>
</body>
</html>
<script>
var jsondata = {}
$(document).ready(function() {
url = //removed to prevent line wrap
$.getJSON(url + "&callback=?",
function(data) { jsondata = data; } );
});
</script>
It produced the same unexpected token error. Any ideas?
Upvotes: 0
Views: 1997
Reputation: 10292
You need to separate your URL path from your parameters with a ?
, not a &
. The server doesn't like your request because it can't find a resource named accel-partners.js&callback=
. It does, however, know of a resource named accel-partners.js
.
Try this:
$(document).ready(function() {
url = //removed to prevent line wrap
var callback = ???; // Make sure to define your callback here
$.getJSON(url + "?callback=" + callback,
function(data) { jsondata = data; } );
});
Upvotes: 3