I'm building a nice app with CodeIgniter and Ajax JQuery which returns finally a nice JSON like object looking like the following out of the success function via console.log ():
var data2 = {"field":fieldname,
"pagetitle":userdata};
$.ajax({
type: "POST",
url: "getdata_ajax",
dataType: 'json',
data: data2,
success: function(data) {
console.log(data);
}
});
The result of the success function:

Since quite a while I'm trying to get just one value out of that object. I tried
console.log (data.id) console.log (data[id]) but nothing worked. I'm sure its just a stupid thing. Any help?
data is an array in this case so use an index to get the first object:
data[0].id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With