我正在尝试使用一些IMDB API来获取有关电影的一些信息的代码,但我收到两个我无法解决的错误...
这是代码:
<body>
<h1>The bourne Legacy</h1>
<h2>2012</h2>
<script>
(function() {
function getMovieInfo( title, year ) {
$.ajax({
type : 'GET',
url: "http://www.deanclatworthy.com/imdb/",
dataType: 'jsonp',
data: { 'q': title, 'year': year },
success: function(info) {
console.log(info.year);
}
});
}
getMovieInfo( $('h1').text(), $('h2').text() );
})();
</script>
</body>
,错误是下一个:
Resource interpreted as Script but transferred with MIME type text/html: "http://www.deanclatworthy.com/imdb/?callback=jQuery18108839007553178817_1347625688866&q=The+bourne+Legacy&year=2012&_=1347625688869". jquery.min.js:2
Uncaught SyntaxError: Unexpected token : www.deanclatworthy.com:1
答案 0 :(得分:0)
function getMovieInfo( title, year ) {
$.ajax({
type : 'GET',
url: "http://www.deanclatworthy.com/imdb/",
dataType: 'json',
data: { 'q': title, 'year': year },
success: function(info) {
console.log(info.year);
}
});
}
getMovieInfo( $('h1').text(), $('h2').text() );
});