'use strict'; var server = 'https://itunes.apple.com/'; var $videosList = $('#videos-list'), $searchForm = $('#search-form'); $searchForm.on('submit', function(event) { event.preventDefault(); var searchString = $('[name="srch-term"]', this).val(); requestVideos(searchString); }); function requestVideos(title) { var request = $.ajax({ url: `${server}/search?term=${title}&limit=5&entity=musicVideo`, method: 'GET' }); request.done((response) => { var responseJson = JSON.parse(response); if (!responseJson.hasOwnProperty('results')) return; var videos = responseJson.results; $('#myCarousel').removeAttr('hidden'); $('.carousel-inner').empty(); videos.forEach((video) => { var $item = $('
').addClass('item'), $carouselCaption = $('
').addClass('carousel-caption').appendTo($item); var $video = $('