我正在使用设计应用程序接口 https://quotesondesign.com/api-v4-0/上的报价,以显示设计师在我的网站上的随机报价。
然而,的想法是显示报价,但只由特定的设计师随机。
我下面的代码不能工作。你知道我为什么要这么做,又该怎么做才能得到想要的结果吗?
$.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');
});
https://stackoverflow.com/questions/44996035
复制相似问题