<input type="search" placeholder="Search for a album or band" id="song">
$(document).ready(function() {
$('form').submit(function(evt) {
evt.preventDefault();
var $searchField = $('#search');
var albums = $searchField.val();// Specifies type of user info to be retrieved and sent to Spotify API
var spotifyOptions = {
"type": "album",
"q": "artist",
"limit": "limit"
}; // Requests data from spotify API. Must be a JavaScript Object
function displayAlbums(data){
var albumHTML = '<ul>'; // Opening ul tag to hold a single album result
$.each(data.items, function(i, album){
albumHTML += '<div class="album" album-id="' + index + '">';
albumHTML += '<li>'; // You may need to use bootstrap to style array items correctly
albumHTML += '<a href="#">';
albumHTML += '<img src="' + album.images[0].url + '" alt="' + album.artists[1].name + '">';
albumHTML += '</a>';
albumHTML += '</div>';
return albumHTML;
}
albumHTML += '</ul>';
$('#music').html(albumHTML);
});
}
$.getJSON(spotifyAPI, spotifyOptions, displayAlbums); // Currently, these are only placeholders. The variables inserted as arguments have not been defined as variables
});
});