0

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:

chrome console attempts

$.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?

1 Answer 1

3

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; } );
});
Sign up to request clarification or add additional context in comments.

1 Comment

Dang it. Thanks. I didn't catch that typo for over 30 minutes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.