David Tang / ITP 404 / 2015
Functionality
Data
Content
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
Functionality
Data
Content
{
"artistType":"Artist",
"artistName":"Jack Johnson",
"artistLinkUrl":"https://itunes.apple.com/us/artist/jack-johnson/id909253?uo=4",
"artistId":909253,
"amgArtistId":468749,
"primaryGenreName":"Rock",
"primaryGenreId":21
}
JS Object Notation (JSON)
API (different domain)
API (same domain)
AJAX w/ CORS
JSONP
AJAX
<script src="https://itunes.apple.com/search?term=jack+johnson&callback=processArtist">
</script>
JSONP query string parameter often called "callback", but not always
function processArtist(artistData) {
var html = '';
artistData.results.forEach(function(result) {
html += '<li>' + result.trackName + '</li>';
});
$('ul#results').html(html);
}