Skip to content

Instantly share code, notes, and snippets.

@brycedorn
Created May 28, 2013 20:44
Show Gist options
  • Save brycedorn/5665969 to your computer and use it in GitHub Desktop.
Save brycedorn/5665969 to your computer and use it in GitHub Desktop.
The actual function as described in the tutorial on mah blog.
function top_artists(){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","http://ws.audioscrobbler.com/2.0/user/BDORN/weeklyartistchart.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("artist");
for (i=0;i<8;i++)
{
document.write("<li>");
document.write("<a href='");
document.write(x[i].getElementsByTagName("url")[0].childNodes[0].nodeValue);
document.write("'>");
document.write(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
document.write(" (");
document.write(x[i].getElementsByTagName("playcount")[0].childNodes[0].nodeValue);
document.write(")");
document.write("</a>");
document.write("</li>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment