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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -