Hi am newbie to JSON i dont know how to iterate JSON over $.each function i worked on it but it display always shows value as undefined am not sure why it is
here how my json looks saved it as new file data.json
{ "users":[
{
"firstName":"Ray",
"lastName":"Villalobos",
"joined": {
"month":"January",
"day":12,
"year":2012
}
},
{
"firstName":"John",
"lastName":"Jones",
"joined": {
"month":"April",
"day":28,
"year":2010
}
}
]}
here i need to iterate name with Joined date in JSon and i iterate it over Jquery by like this
$(function(){
$(document).on('click', '.users', function(e){
e.preventDefault();
$.getJSON( "js/data.json", function( data ) {
var items = [];
$.each( data.users, function( key, val ) {
console.log(data.users);
items.push( "<li id='" + data.users.firstName + "'><span><p>" + data.users.firstName + "</p></span></li>" );
});
$( "<ul/>", {
"class": "users-lists",
html: items.join( "" )
}).appendTo( ".nlst" );
});
});
});
help me out