Reading Json Data in Javascript / php (Format issue) -
i have code reads json data below (this code works well):
var data = [{"id":1, "start":"2011-10-29t13:15:00.000+10:00", "end":"2011-10-29t14:15:00.000+10:00", "title":"meeting"}]; var output = ''; $.each(data, function(index, value){ output += '<li>' + value.title + '</li>'; });
ive changed data (see below) , reason it's not working
var data = {"users":[{"firstname":"peter","lastname":"tosh"},{"firstname":"mike","lastname":"marsh"}]} var output = ''; $.each(data, function(index, value){ output += '<li>' + value.firstname + '</li>'; });
i know data format different ... i'm forgetting something?
$.each(data.users, function(index, value){ output += '<li>' + value.firstname + '</li>'; });
try this
Comments
Post a Comment