0
簡単にするために、ajaxはフラスコからjsonify応答を受け取り、htmlでレンダリングする方法を見つけることができません。 私が試した:jsonifyフラスコ解析エラー
success: function(json) {
$.each(json, function(index, element) {
$('#main').append(element.title);
});
}
と "未定義" に印刷ました。
は、その後、私が試した:
$('#main').append(json[index].name)
が、何も
を印刷しないしまった。ここAPIによって返されたJSONです:
{
"albums": [
{
"artist_id": 19,
"composer_id": 3,
"id": 6,
"img": "The_Fine_Art_of_Self_Destruction.jpg",
"release_date": 2002,
"title": "the fine art of self destruction"
},
{
"artist_id": 26,
"composer_id": 6,
"id": 22,
"img": "The_Blasters_%28album%29.jpg",
"release_date": 1981,
"title": "the blasters"
},
{
"artist_id": 25,
"composer_id": 6,
"id": 25,
"img": "XMoreFunInTheNewWorld.jpg",
"release_date": 1983,
"title": "more fun in the new world"
},
{
"artist_id": 27,
"composer_id": 8,
"id": 28,
"img": "220px-The_Angels_of_Light_Sing_%27Other_People%27.jpeg",
"release_date": 2005,
"title": "the angels of light sing 'other people'"
},
{
"artist_id": 10,
"composer_id": 10,
"id": 32,
"img": null,
"release_date": 2008,
"title": "when the flood comes"
},
{
"artist_id": 31,
"composer_id": 15,
"id": 40,
"img": "The_Willies.jpg",
"release_date": 2002,
"title": "the willies"
}
]
}
私はjQuery.parseJSON(のような多くの物事を見て)と他は何も働いていない。
ありがとうございました!
'JSON [インデックス]' json.albums [インデックス] .name'ことになって.name'する必要があります –