【发布时间】:2012-03-11 22:27:38
【问题描述】:
我正在尝试使用自动完成功能从 rottentomatoes 获取 JSON 格式的电影建议。 但是下面的代码没有显示任何建议。
<script>
var apikey = "5xq9w7z2mp7a6cnchkfy52yd";
var baseUrl = "http://api.rottentomatoes.com/api/public/v1.0";
var moviesSearchUrl = baseUrl + '/movies.json?apikey=' + apikey;
var query = "Rocky";
$(document).ready(function() {
$("#sample").autocomplete({
source: function( request, response ) {
$.ajax({
url: moviesSearchUrl + '&q=' + encodeURI(query),
dataType: "jsonp",
success: function(data) {
var movies = data.movies;
response(function(movies) {
return {
label: movies.title,
value: movies.title
}
}));
}
});
}
});
});
</script>
完整页面来源:https://gist.github.com/2018447 我还需要在建议列表中包含电影缩略图。谁能帮我解决这个问题?
【问题讨论】:
-
你的错误控制台说什么?
-
b[0] 未定义文件://home/aaa/jqueryexample/js/jquery-ui-1.8.18.custom.min.js
-
我已更新我的答案以包含海报缩略图。这应该可以解决您的问题
标签: javascript jquery jquery-ui jquery-autocomplete rotten-tomatoes