使用Ajax显示来自两个节点的Json

使用Ajax显示来自两个节点的Json,ajax,json,Ajax,Json,我很难显示来自json的数据。Title显示精细但项。volumeInfo.industryIdentifiers。type返回未定义项 $.ajax({ url: 'https://www.googleapis.com/books/v1/volumes?q=:isbn=0-13-727827-6', dataType: 'json', success: function (data) { $.each(data.items, function (index, item) {

我很难显示来自json的数据。Title显示精细但项。volumeInfo.industryIdentifiers。type返回未定义项

$.ajax({
url: 'https://www.googleapis.com/books/v1/volumes?q=:isbn=0-13-727827-6',
dataType: 'json',
success: function (data) {
    $.each(data.items, function (index, item) {
        $(".tab1").append("<div>" + item.volumeInfo.title + "</div><div>" + item.volumeInfo.industryIdentifiers.type + "</div>");
    });
}
});
$.ajax({
网址:'https://www.googleapis.com/books/v1/volumes?q=:isbn=0-13-727827-6',
数据类型:“json”,
成功:功能(数据){
$.each(数据项、函数项、索引项){
$(“.tab1”).append(“+item.volumeInfo.title+”+item.volumeInfo.industryIdentifiers.type+”);
});
}
});
小提琴在这里:


非常感谢您的帮助。

您需要将[0]放在前面。按卷键入信息可以有两个行业标识。当然,这只会显示第一个,因此如果存在多个,您可能需要找到更合适的方式来显示这两个

$.ajax({
    url: 'https://www.googleapis.com/books/v1/volumes?q=:isbn=0-13-727827-6',
    dataType: 'json',
    success: function (data) {
        $.each(data.items, function (index, item) {
            $(".tab1").append("<div>" + item.volumeInfo.title + "</div><div>" + item.volumeInfo.industryIdentifiers[0].type + "</div>");
        });
    }
});
$.ajax({
网址:'https://www.googleapis.com/books/v1/volumes?q=:isbn=0-13-727827-6',
数据类型:“json”,
成功:功能(数据){
$.each(数据项、函数项、索引项){
$(.tab1”).append(“+item.volumeInfo.title+”+item.volumeInfo.industryIdentifiers[0].type+”);
});
}
});

解决方案不是很难。david99world建议再做一次$。每个$循环浏览每个项目并指向一把小提琴。我稍微修改了一下,并提出:

$.ajax({
url: 'https://www.googleapis.com/books/v1/volumes?q=:isbn=0-13-727827-6',
dataType: 'json',
success: function (data) {
    $.each(data.items, function (i, item) {
        $(".tab1").append("<div>" + item.volumeInfo.title + "</div>");
        $.each(item.volumeInfo.industryIdentifiers, function (i2, type) {
            $(".tab1").append("<div>" + type.type + "</div>");
        });
    });
}
});
$.ajax({
网址:'https://www.googleapis.com/books/v1/volumes?q=:isbn=0-13-727827-6',
数据类型:“json”,
成功:功能(数据){
$.each(data.items,function(i,item){
$(“.tab1”).append(“+item.volumeInfo.title+”);
$.each(item.volumeInfo.industryIdentifiers,函数(i2,类型){
$(“.tab1”).append(“+type.type+”);
});
});
}
});


希望它对其他人有用。

david99world您能建议显示几个实例的解决方案吗?我会说再做一次$。每个项目都有一个循环,具体取决于您希望显示的内容:)您能添加$吗?请在JSFIDLE上为我的循环添加每个实例?非常抱歉,我很愚蠢,我不太了解ajax和jquery。我不是100%确定,我还没有真正的时间来编写查询,写一个新问题询问如何迭代嵌套的json对象,您可能会从中获得更多乐趣:)