Skip to content

Commit 7b1e273

Browse files
"Added sample: javascript/search.js"
1 parent e9ae998 commit 7b1e273

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

javascript/search.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// After the API loads, call a function to enable the search box.
2+
function handleAPILoaded() {
3+
$('#search-button').attr('disabled', false);
4+
}
5+
6+
// Search for a specified string.
7+
function search() {
8+
var q = $('#query').val();
9+
var request = gapi.client.youtube.search.list({
10+
q: q,
11+
part: 'snippet'
12+
});
13+
14+
request.execute(function(response) {
15+
var str = JSON.stringify(response.result);
16+
$('#search-container').html('<pre>' + str + '</pre>');
17+
});
18+
}

0 commit comments

Comments
 (0)