我正在使用 OMDb API 来获取一些电影信息。
我使用的功能是这个:
function getImage(titel) {
$.ajax({
type: "GET",
dataType: "json",
url: "http://www.omdbapi.com/?t=" + titel,
success: function(data){
return data.Poster;
},
async:false,
error: function() {
return "Image not found.";
}
});
}
服务器返回的一个示例:
{
"Title":"The Godfather",
"Year":"1972",
"Rated":"R",
"Released":"24 Mar 1972",
"Runtime":"2 h 55 min",
"Genre":"Crime, Drama",
"Director":"Francis Ford Coppola",
"Writer":"Mario Puzo, Francis Ford Coppola",
"Actors":"Marlon Brando, Al Pacino, James Caan, Diane Keaton",
"Plot":"The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son.",
"Poster":"http://ia.media-imdb.com/images/M/MV5BMjEyMjcyNDI4MF5BMl5BanBnXkFtZTcwMDA5Mzg3OA@@._V1_SX300.jpg",
"imdbRating":"9.2",
"imdbVotes":"755,007",
"imdbID":"tt0068646",
"Type":"movie",
"Response":"True"
}
给定的title是参数填写的,omdbapi返回的数据是正确的。只有 data.Poster 不起作用。我究竟做错了什么?