Upon this json rest object:
[{"id_film":1,"title":"Forrest Gump","director":"Zameckis","year":"1994","price":"12.00","format":"DVD"},{"id_film":4,"title":"Back to the Future II","director":"Zameckis","year":"1989","price":"9.95","format":"DVD"}]
I am trying to build a response in a web page using the $getJSON function and place the response in a div id="films", but I do not know how to get to the 'title' and 'director' json properties.
$.getJSON( "http://rest/url", function( data ) {
var items = [];
$.each( data, function( title, director ) {
items.push( "<li id='" + title + "'>" + director + "</li>" );
});
$( "<ul/>", {
"class": "my-new-list",
html: items.join( "" )
}).appendTo( "#films" );
});
In the response only appears an unordered list of:
[object Object]
[object Object]
What I could do to get a list of 'title' and 'director' unordered list?
Thanks