0

我正在尝试解析这个 JSON 并从中提取所有数据。我不是解析它的专家,所以如果有人可以提供帮助会很好吗?

http://jsfiddle.net/NJMyD/1044/

html

 <div class="items">
      <div class="item">
        <a href="#">
          <figure>
            <span><img src="" /></span>
            <figcaption>
              <h2 class="pod-title">
                <em data-title="Title of Show"></em>
              </h2>
              <p class="subtitle"></p>
            </figcaption>
          </figure>
        </a>
      </div>
    </div>
4

1 回答 1

0

好的,您的代码中有很多错误的东西(什么应该在str?,src并且url不存在于 JSON 对象中,等等......)。

这是返回所有的修改后的脚本object.href

function getResults(str) {
   $.ajax({
    type: "GET",
    async: true,
    dataType: "jsonp",
    url: 'http://api.stb.search.sky.com/query.json?category=stb&term=andy+murray&sid=sport&adult=true&bouquet=4101&subbouquet=1&epgInfoBits=00020000&epgInfoBitsMask=001a0000&page=1&items=16&uid=4170198908',
    success: function(data){
    console.log(data);
     $.each(data, function() {
      $('.items').append(data.href+'<br />'); // <- do what you want here
     });
    }
   });
} 

PS:您必须使用 JSONP 数据类型进行跨域 ajax 查询!

于 2013-10-30T10:48:02.673 回答