首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >过滤JSON以获得特定结果

过滤JSON以获得特定结果
EN

Stack Overflow用户
提问于 2017-07-09 19:44:24
回答 1查看 260关注 0票数 0

我正在使用设计应用程序接口 https://quotesondesign.com/api-v4-0/上的报价,以显示设计师在我的网站上的随机报价。

然而,的想法是显示报价,但只由特定的设计师随机

我下面的代码不能工作。你知道我为什么要这么做,又该怎么做才能得到想要的结果吗?

代码语言:javascript
复制
    $.ajaxSetup(
{  cache: false}
);

function newQuote(){
  $.getJSON('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=', function(json,data){
 // Filter to return quotes by Steve Jobs only
    return json.filter(function(data){
      return (data[0].title == "Steve Jobs")
    });
    // add the quote(data[0].content) to my page.
    $('.quote_text').html(data[0].content);
  });

}
// get a new quote everytime i click the button (.message_btn)
$(document).ready(function(){
  newQuote();
  $('.message_btn').on('click',newQuote).fadeIn('slow');
});
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44996035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档