Ich muss JSON -Dateikommentare nach ID in meinem Blog anzeigen
Posted: 10 Feb 2025, 08:42
Ich weiß nicht, wie man die JSON -Datei anruft, damit sie im Blog angezeigt wird. Ich habe diese Methode ausprobiert, aber sie funktioniert nicht. Ich denke, ich muss jede Schleife verwenden, aber das einzige, was ich bekomme, ist ein Fehler. ">
Code: Select all
$.ajax({ type: "GET", url: "https://jsonplaceholder.typicode.com/comments", dataType: 'json', success: function (comment) {
console.log(comment);
commentsOn();
}
});
function commentsOn(comments) {
$("#comm").append(
"postId:" + comments.postId +
"ID:" + comments.id + "" +
"Name:" + comments.name + "" +
"Email:" + comments.email + "
" +
"Body:" + comments.body + "" + ""
);
}