Posts

Showing posts from February, 2016

Running searches on YouTube is easy with jQuery and the YouTube APIs.

We start from the following markup:
<body> <form action="" method="get" id="search-youtube"> <div> <input type="text" name="q" id="q" /> <input type="submit" value="Search" /> </div> </form> <div id="response"></div> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="app.js"></script> <script src="https://apis.google.com/js/client.js?onload=init"></script> </body> The init() method must be global. We can build our code as follows:
(function( $ ) { var App = { init: function() { gapi.client.setApiKey( "API key" ); gapi.client.load( "youtube", "v3", function() { App.getVideos(); }); }, getV…