I use omdb api to list the movies and used ajax inside ajax while doing this but having trouble doing rendering.
console.log : https://i.stack.imgur.com/bu7bb.png
$(function(){
$('#search').autocomplete({
source: function( request, response ) {
$.ajax( {
url: 'http://www.omdbapi.com?s='+ request.term +'&apikey=daee70b3',
dataType: 'json',
data: {
movie:request.term
},
success: function( data ) {
jQuery.each(data.Search, function(index, item) {
var imdb = item.imdbID;
$.ajax({
url: 'http://www.omdbapi.com?i='+ imdb +'&apikey=daee70b3',
dataType: 'json',
data: {
movieDetail:imdb
},
success: function (data) {
console.log(data);
}
});
});
response(data.Search);
}
});
}
});
$('#search').data('ui-autocomplete')._renderItem = function( ul, item ){
var $li = $('<li>');
$li.html(
'<img style="width: 100%;" src="' + item.Poster + '" />' +
'<span class="username">' + item.Title + '</span>'
);
return $li.appendTo(ul);
};
});
What I want to do first is to list the movies with http://www.omdb.com/?s="movie-title then to bring the details with http://www.omdb.com/?i="imdbID "How can I do it?"