I am loading JSON data from a movie database API. The AJAX loads within a search function, it works fine but then disappears. Here's the code:
<div class="form-group">
<label for="movie">inserisci film:</label>
<input type="text" class="form-control" id="movie" type="text"></input>
</div>
<button type="submit" onclick="search()" class="btn btn-default">cerca</button>
Then I call the function
function search() {
var film = document.getElementById('movie').value;
var key = '?api_key=somekey';
alert(film + key);
$.ajax({
type: 'GET',
url : 'http://api.themoviedb.org/3/search/movie'+key+'&query='+film,
async: false,
data: {
format: 'json'
},
success: function(data){
$('#titolo').append(data.results[0].original_title);
$('#immagine').append('<img src=' + url + key + ata.results[0].poster_path + '></img>');
console.log(data);
},
});
};
there is something wrong? thank you
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…