我正在使用jquery嘗試瀏覽紐約時報api。我連接到服務器並獲得JSON響應,但是我無法正確地遍歷JSON對象,並且我的項目中沒有任何內容。
這是我的代碼:
如何瀏覽NYT API JSON返回?
var url = "http://api.nytimes.com/svc/search/v2/articlesearch.json?q=new york&page=1&api-key=9e4043438fa8df45282e8e570e9ac5ed:5:74988126";
$.getJSON(url, function (data) {
var items = [];
$.each(data, function(key, val){
items.push("<li> <a href='" + response.docs[0].web_url + "' >" + response.docs[0].abstract + "</a>" + "<p>" + response.docs[0].snippet + "</p>");
});
console.log(items);
});
這裏有一個鏈接到紐約時報API指南:http://developer.nytimes.com/docs/read/article_search_api_v2
什麼我做錯了,我該如何解決?
非常感謝您的時間,精力和幫助。
這裏有什麼反應??? – nisar