Skip to content

Instantly share code, notes, and snippets.

@cbrumelle
Created March 15, 2010 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbrumelle/332648 to your computer and use it in GitHub Desktop.
Save cbrumelle/332648 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="prototype.js"></script>
<script language="javascript" type="text/javascript" src="jsonp.js"></script>
<title>JSONP test page</title>
</head>
<body>
<script>
new Ajax.JSONRequest('http://labs.mixedcontent.com/listens/artist/location', {
callbackParamName: "JSONPCallback",
parameters: {
"ArtistKey" : 'http://radio3.cbc.ca/play/band/The-Deep-Dark-Woods',
"Date[from]" : "2010-01-01",
"Date[to]" : "2010-01-15"
},
onSuccess: function(response) {
//Called when URL returns valid data...
plays = response.responseJSON;
//'recommendations' is now an array of JSON objects...
//For demo purposes, build a list of plays.
var output = '<ul>';
plays.forEach(function(play) {
output += "<li>Plays: " + play.Playcount + " : " + play.City + ", " + play.Region + "</li>";
});
output += "</ul>";
$('result').update(output);
}
});
</script>
<div id="result"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment