【问题标题】:Parsing JSON from IMDb API从 IMDb API 解析 JSON
【发布时间】:2014-07-23 16:56:24
【问题描述】:

我找到了一种从 IMDb 中以舒适的 JSON 格式提取有关电视节目或电影的数据的方法: http://imdbapi.com/?t=query
非常棒,但是当我尝试使用本地 JS 实际使用数据时,它不起作用。

var data = $.ajax({
  dataType: "json",
  async: false, 
  cache: false,
  crossDomain: true,
  jsonp: true,
  url: "http://imdbapi.com/?t=lost", 
  success: function() {
    console.log( 'loaded successfuly. ' )
  },
});
var poster = data.Poster;
console.log( poster );

由于 CORS,我正在使用 JSONP。这是控制台显示的内容:
"加载成功。
不明确的”
我不知道是什么问题!请帮忙。
- 奥伦

【问题讨论】:

    标签: jquery json api jsonp imdb


    【解决方案1】:

    当您使用数据时,它可能没有被设置......好吧,情况就是这样;)。确保将您的代码放入成功方法中。

     $.ajax({
    dataType: "json",
      async: false, 
      cache: false,
      crossDomain: true,
      jsonp: true,
      url: "http://imdbapi.com/?t=lost", 
      success: function(data) {
    
        var poster = data.Poster;
        console.log(poster);
        console.log( 'loaded successfuly. ')
      },
    });
    

    【讨论】:

    • 复制/粘贴然后懒得以正确的方式纠正它。我编辑了,现在你已经知道了。
    • imdbapi.com 不再工作使用这个theimdbapi.org
    猜你喜欢
    • 2014-07-20
    • 2016-09-23
    • 2011-11-30
    • 2022-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多