I'm trying to use autocomplete for getting movie suggestion from rottentomatoes in JSON format. But the code below doesn't show any suggestion.
<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>
For the complete page source: https://gist.github.com/2018447 I also need to include the movie thumbnail in the suggestion list. Could anyone help me on this?