Google api 谷歌图书api:如何显示标题?
我正在做一个练习,我需要为我的网页提供一个AJAX提要。因为我的网站是关于书籍的,所以我使用的是谷歌图书API。 不过我不知道如何显示书名。这是我目前掌握的代码:Google api 谷歌图书api:如何显示标题?,google-api,google-books,Google Api,Google Books,我正在做一个练习,我需要为我的网页提供一个AJAX提要。因为我的网站是关于书籍的,所以我使用的是谷歌图书API。 不过我不知道如何显示书名。这是我目前掌握的代码: $(document).ready(function(){ var url = 'https://www.googleapis.com/books/v1/volumes?q=:a'; $.get(url, function(data,status){ console.log(data); var in
$(document).ready(function(){
var url = 'https://www.googleapis.com/books/v1/volumes?q=:a';
$.get(url, function(data,status){
console.log(data);
var intValue =data.totalitems;
var strOne =data.kind;
var items = data.items;
$.each(items, function( index, value) {
console.log(value.title);
$('#div1').append('<li><div>'+value.title+'</div></li>') });
});
});
});
$(文档).ready(函数(){
var url='1〕https://www.googleapis.com/books/v1/volumes?q=:a';
$.get(url、函数(数据、状态){
控制台日志(数据);
var intValue=data.totalitems;
var strOne=data.kind;
var items=data.items;
$。每个(项目、功能(索引、值){
console.log(value.title);
$(“#div1”).append(“”+value.title+“ ”)});
});
});
});
尝试以下操作
JS
$.each(data.items, function(entryIndex, entry){
var html = '<div class="results">';
html += '<h3>' + ( entry.volumeInfo.title || '' )+ '</h3>';
$(html).hide().appendTo(".result");
});
$.each(data.items,function(entryIndex,entry){
var html='';
html+=''+(entry.volumeInfo.title | |'')+'';
$(html.hide().appendTo(“.result”);
});
html
<div class="result"></div>