samedi 18 avril 2015

I am getting undefined from the Jquery function "getJSON"


$.getJSON('SampleUserData.json', function(data) {

var output="<ul>";
$.each(data, function (index, val) {
output+="<li>" + String(val.id) + " " + String(val.lastName) + "--" +"</li>";
})

output+="</ul>";
document.getElementById("placeholder").innerHTML=output;
});


Returns



undefined undefined--
undefined undefined--
undefined undefined--
undefined undefined--
undefined undefined--
undefined undefined--
undefined undefined--


The JSON is below



[
{
"First Name": "Pascale",
"Last Name": "Hood",
"Address": "827-448 Magna Rd.",
"City": "Burlington",
"Zip": "38459",
"ID": "71480845"
},
{
"First Name": "Odette",
"Last Name": "Rich",
"Address": "7923 Pede. Rd.",
"City": "Bothey",
"Zip": "14394",
"ID": "65839483"
},
{
"First Name": "Christen",
"Last Name": "Hardin",
"Address": "390-1605 Adipiscing Street",
"City": "Oudergem",
"Zip": "90085",
"ID": "78046404"
},
{
"First Name": "Uma",
"Last Name": "Cunningham",
"Address": "313-1839 Lorem Av.",
"City": "San Cristóbal de la Laguna",
"Zip": "99153",
"ID": "27367690"
}
]


Any help would be appreciated.


Aucun commentaire:

Enregistrer un commentaire