Skip to content

Instantly share code, notes, and snippets.

@philmein23
Last active October 24, 2015 00:58
Show Gist options
  • Save philmein23/683c0b91a90a3d4f0885 to your computer and use it in GitHub Desktop.
Save philmein23/683c0b91a90a3d4f0885 to your computer and use it in GitHub Desktop.
You Tube
$(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';
$.getJSON(url, params, function(data){
showResults(data.Search); //unsure here
})
}
function showResults(results) {
var html = "";
for (var i = 0; i < results.length; i++) {
var myData = results[i]; //need to re-configure for youtube
html += "<p>" + myData + "</p>"; //need to configure for youtube
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