Skip to content

Instantly share code, notes, and snippets.

@kopiro
Created October 27, 2011 15:46
Show Gist options
  • Save kopiro/1319942 to your computer and use it in GitHub Desktop.
Save kopiro/1319942 to your computer and use it in GitHub Desktop.
Load the latest LastFM song in jQuery
loadLastFmSong = function(user, api) {
$.getJSON("http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user="+user+"&api_key="+api+"&format=json&callback=?",
function(json) {
lastfmtrack = json.recenttracks.track[0];
$("#lastfm_song").html('<a target="_blank" href="'+lastfmtrack.url+'">'+lastfmtrack.name+", di "+lastfmtrack.artist["#text"]+'</a>');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment