javascript - Trying to make a youtube search function on my website with the youtube api -
as title says, i'm trying make youtube search function on website. i've got far:
$(document).ready(function() { $("#searchbutton").click(function (e) { e.preventdefault(); var searchinput = $("#search"); $.get( "https://www.googleapis.com/youtube/v3/search", { part: 'snippet', maxresults: 1, q: searchinput, key: 'my_key' }, function (data) { console.log(data.items.id.videoid); } ); });
});
when press #searchbutton, puts input in 'searchinput' , puts searchinput in 'q'. here html-code:
<form> <input type="text" id="search"/> <button type="submit" id="searchbutton">find</button> </form>
for i'm trying make videoid output in console. problem when click on searchbutton, whole website doesn't respond anymore. can still use other websites @ moment, websites won't respond anymore. know variable 'searchinput' problem, because whenever type 'dog' in 'q', give me videoid dog video. know why 'searchinput' makes website not respond? or there maybe better way whole youtube search thing?
Comments
Post a Comment