I've been trying to retrieve JSON data, but I seem to have hit a snag. I'm not sure where I went wrong or how to correct it.
[
{
"userId": 1,
"title": "A",
"body": "B"
},
{
"userId": 1,
"title": "C",
"body": "D"
},
{
"userId": 2,
"title": "E",
"body": "F"
},
function loadPost (y) {
$.getJSON(
function(data){
var i;
while (y = data[i].userId) {
$("#card").append(
"<p><span class='postTilte'>" + data[i].title +
"</span>"+ data[i].body + "</p>"
)
}}
When this is clicked, the function will execute and display the desired information based on the provided number for variable y.
Can anyone offer assistance?