2012-09-14 46 views
0

我想創建一個代碼,將獲得一些關於使用IMDB API的電影信息,但我得到兩個錯誤,我無法修復...錯誤,而試圖讓jQuery與jquery

這是代碼:

<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
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()); 

}); 
+0

不工作...仍然是同樣的錯誤,我編輯上面的代碼 –