I want GET json from http://omadbapi.com/?s= for search script, but I'm having trouble with get Title elment in this JSON :
{
"Search": [
{
"Title": "Sherlock Holmes: A Game of Shadows",
"Year": "2011",
"imdbID": "tt1515091",
"Type": "movie"
},
{
"Title": "Spy Kids 3-D: Game Over",
"Year": "2003",
"imdbID": "tt0338459",
"Type": "movie"
}
]
}
JavaScript :
$(document).ready(function () {
var url = 'http://www.omdbapi.com/?',
mode = 's=',
input,
movieName;
$('button').click(function() {
var input = $('#movie').val(),
movieName = encodeURI(input);
$.getJSON( url + mode + input, function( data ) {
$.each(data, function(e,p) {
document.getElementById("item").innerHTML="Title : " + p.Title;
});
});
});
});
p.Title or data.Title, I don't know...
Aucun commentaire:
Enregistrer un commentaire