How can I get access to this JSON Array using jQuery? I've currently processed the array from an API to the console.log()
which is displayed in this format
Object {already_liked: false, media_id: "1234567890", likeResult: Object}
already_liked: false
likeResult: Object
data: null
meta: Object
code: 200
__proto__: Object
__proto__: Object
media_id: "1234567890"
__proto__: Object
I am getting this response from an AJAX request which is formatted in such way
$.get('/likemedia', {
mediaid: $(this).data("id")
}, function(data){
console.log(data.html);
}, 'json');
The response from /likemedia
is formatted in such way
{"html":{"already_liked":false,"media_id":"1234567890","likeResult":{"meta":{"code":200},"data":null}}}
I then tried acessing the JSON array key of "meta['code']" using this format
data.html.likeResult.meta.code
Which was to now avail, how can I get the value of 'data.likeResult.meta.code'?
I attempted to do the following which results in it throwing the array into the console.log
if (data.html.likeResult.meta.code === "200") {
alert("200 META CODE!");
} else {
console.log(data.html);
}