$.getJSON('dat.js', function(i,data) {
$( "#lessons" ).tmpl( data[1].title ).appendTo( "#result" );
});
my json file
{
"posts": [
{
"title": "ajax | Programming ",
"url": "hello"
},
{
"title": "jQuery and Ajax Demos Pard - 3",
"url": "how are you"
},
]
}
i want to access the name field but data[0] is showing error as undefined,
Your JSON seems invalid. Keys must be wrapped in quotes, so each object looks like
Use JSONLint.com to validate JSON strings.
Live Demo