I'm making a cinema schedule page for my own use, but I'm facing a problem. I want to make the page popup the info for the movie I click, but it always shows the info for the last movie in the list.
I'm sure it's something simple, but I just don't see it.
the code I use to get the info I need :
var settings = {
"async": true,
"crossDomain": true,
"url": ("https://api.themoviedb.org/3/search/movie?api_key=e8a6a870421f5cc13e775873bfe1cad8&language=bg&query=")+encodeURIComponent(fn),
"method": "GET",
"headers": {},
"data": "{}"
}
$.ajax(settings).done(function (response) {
var plakat = response.results[0].poster_path;
window.movieId = response.results[0].id;
window.title = response.results[0].title;
window.poster = "https://image.tmdb.org/t/p/w92/"+plakat;
window.overview = response.results[0].overview;
console.log(response.results[0].title);
var k;
for(k=0; k< ttest.length; k++){
document.getElementById('myPopup').innerHTML = ("<img align='left' src="+window.poster+"><h2>"+window.title+"</h2><br>"+window.overview);
}
});
then I want to loop all the result so I can change the data shown in the popup, but it doesn't seem to work.
any help will be much appreciated.