Javascript Youtube API在DW中工作,但在JSFIDLE中发布错误
我已经和Youtube API玩了几天了,这只是我的第二个项目。我刚刚完成了FlickrAPI,所以我想我应该试试youtube 代码在dreamweaver中工作,但在JSFIDLE中不工作。我想这与提交有关,但在过去的几个小时里我一直在玩弄它,肯定错过了什么 非常感谢您的任何意见Javascript Youtube API在DW中工作,但在JSFIDLE中发布错误,javascript,youtube,youtube-api,youtube-javascript-api,youtube-data-api,Javascript,Youtube,Youtube Api,Youtube Javascript Api,Youtube Data Api,我已经和Youtube API玩了几天了,这只是我的第二个项目。我刚刚完成了FlickrAPI,所以我想我应该试试youtube 代码在dreamweaver中工作,但在JSFIDLE中不工作。我想这与提交有关,但在过去的几个小时里我一直在玩弄它,肯定错过了什么 非常感谢您的任何意见 <script src="https://apis.google.com/js/client.js?onload=loaded" type="text/javascript"></script&g
<script src="https://apis.google.com/js/client.js?onload=loaded" type="text/javascript"></script>
</head>
<body>
<body>
<h1 id="header"> Search YouTube </h1>
<section id="center">
<form id="theform">
<p><input type="text" name="term" id="term" value="dog"></p>
<p><input type="submit" id="submit" value="Search"></p>
</form>
</section>
<div id='here'> Here: </div>
<pre id="response"></pre>
</body>
var apiKey = 'myKey';
function showResponse(response) {
var responseString = JSON.stringify(response, '', 2);
document.getElementById('response').innerHTML += responseString;
}
function loaded(event) {
gapi.client.load('youtube', 'v3', gapi.client.setApiKey(apiKey));
}
$("#theform").on("submit", function(e) {
e.preventDefault();
var request = gapi.client.youtube.search.list({
part: 'snippet',
q: document.getElementById('term').value,
maxResults: 1
});
});
request.execute(onSearchResponse);
}
function onSearchResponse(response) {
showResponse(response);
}