0
我正在練習Ajax調用,並且在訪問返回的JSON數據時遇到問題。用jquery操縱json數據
我有以下
$('button').on('click', function() {
$.ajax({
url: 'http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1',
success: function(data) {
console.log(data);
},
error: function() {
console.log('error occured');
},
cache: false
});
});
下面的代碼輸出
[
{
"ID": 1127,
"title": "Paul Rand",
"content": "<p>Good ideas rarely come in bunches. The designer who voluntarily presents his client with a batch of layouts does so not out prolificacy, but out of uncertainty or fear. </p>\n",
"link": "https://quotesondesign.com/paul-rand-7/"
}
]
我只是想給我的輸出JSON對象的content
和link
性能。我已經試過如下:
$('.message').html(JSON.stringify(data));
其輸出
[{"ID":2294,"title":"Josh Collinsworth","content":"
You do not need to have a great idea before you can begin working; you need to begin working before you can have a great idea.
\n","link":"https://quotesondesign.com/josh-collinsworth-3/"}]
我試圖尋找標準的方法來處理JSON數據,感謝所有幫助!
u能澄清指數0? –
是的,我會編輯問題 – miken32
啊。我現在可以清楚地看到一切。謝謝您的幫助!!!使用API的工作已經很棒了! –