0
$(function(){
    $.getJSON('http://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=ElicitBelief&api_key=25135a535781328243f9e31968abc14&format=json', function(data) {
      alert(data)
    });
});

Firebug says: GET http://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=ElicitBelief&api_key=25135a535781328243f9e31968abc14&format=json 200 OK 144ms and the URL is red, so it's presumebly not fetching the data at all.

I can't think what the problem is.

1
  • Is that the same domain as the page? Commented Mar 6, 2010 at 15:29

3 Answers 3

1

Presumably the url is in a different domain. You'll need to use JSONP and add &jsoncallback=? to your query. I assume that the audioscrobbler API supports this.

Sign up to request clarification or add additional context in comments.

Comments

0

Visiting that URL gives me a file that says, "Invalid API key - You must be granted a valid key by last.fm"

Comments

0

According to that link http://www.ibm.com/developerworks/library/wa-aj-jsonp1/, you have to add an "&callback=?" at the end of your URL (reason for this, is that jQuery automaticly uses JSONP to bypass AJAX Cross Domain policy when using $.getJSON).

So, if you pass below url to getJSON: http://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=ElicitBelief&api_key=25135a535781328243f9e31968abc14&format=json&callback=? you'll get JSON respoonse with : "Invalid API key - You must be granted a valid key by last.fm"

Check this for demo: JSBin (page is empty, but look at requests in Firebug console)

Comments

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.