我想从 Google 图书的书架上获取所有标题,并生成一串用逗号分隔的标题。这是我的尝试:
var allTitles = [];
$.getJSON("https://www.googleapis.com/books/v1/users/115939388709512616120/bookshelves/1004/volumes?key=MYAPIKEY",function(data){
$.each(data.items, function (i, item) {
allTitles.push(data.items[0].volumeInfo.title);
});
var newTitleString = allTitles.join(', ');
alert(newTitleString);
http://jsfiddle.net/nathanbweb/YzXLW/
我该如何进行这项工作?