Created
October 24, 2015 21:28
-
-
Save philmein23/ef05e16f1fcf2e74ccfc to your computer and use it in GitHub Desktop.
YouTube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$("#search-term").submit(function(event) { | |
event.preventDefault(); | |
var searchTerm = $("#query").val(); | |
getRequest(searchTerm); | |
}) | |
function getRequest(searchTerm) { | |
var params = { | |
part: 'snippet', | |
key: 'AIzaSyAJH04pfGBf6N34ileppDhtSd5GMZqecto', | |
q: searchTerm //unsure here | |
}; | |
url = 'https://www.googleapis.com/youtube/v3/search'; | |
$.getJSON(url, params, function(data){ | |
//console.log(data); | |
showResults(data.items.snippet.thumbnails.url); | |
}) | |
} | |
function showResults(results) { | |
var html = ""; | |
for (var i = 0; i < results.length; i++) { | |
var myData = results[i]; | |
html += "<p><img src='"+ myData +"'></p>"; | |
console.log(myData); | |
} | |
$("#search-results").html(html); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment