I have a jquery ajax function that works just fine in going out and retrieving data. What I'm experiencing though is that I cannot seem to pull individual json data elements from the returned data using, what I thought was, conventional methods.
$("a[name$='-test']").click(function() {
var rpc_url = '/history/get_test/' + $(this).attr('id');
$.ajax({
url : rpc_url,
type : 'post',
contentType : "application/json; charset=utf-8",
datatype : 'json',
success : function(data) {
console.log(data.id);
}
}).done(function(data) {
console.log(data.title);
});
});
}
Original resulting data was formatted like this;
[{"id":"1","title":"Test title"}]
Then I modified my remote code to just return the data outside of an array context as such;
{"id":"1","title":"Test title"}
As you can see in my code, I tried accessing the data both at the success event and at the done event. Fiddler shows well formatted json as the returned data. Though both continue to yield undefined in the console output for data.id & data.title.
So, am I missing something obvious here?
Thanks.
contentType:setting, which describes sent data, not the response.