Skip to content

Instantly share code, notes, and snippets.

@kopiro
Created October 27, 2011 15:53
Show Gist options
  • Save kopiro/1319955 to your computer and use it in GitHub Desktop.
Save kopiro/1319955 to your computer and use it in GitHub Desktop.
Get top artist from Last.FM with jQuery
loadLastFmArtists = function(user, api, n) {
n = n || 3;
$.getJSON("http://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user="+user+"&api_key=+"api+"&format=json&callback=?",
function(json) {
$(json.topartists.artist).each(function(k, v){
if (k>n) return;
$("#lastfm_artists").append('<a target="_blank" href="'+v.url+'">'+v.name+"</a>, ");
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment