I've been attempting to extract specific field values from a JSON object retrieved from the Facebook Graph API using an AJAX call in JavaScript.
The code I'm utilizing to access the cover field from the JSON object is not providing the desired results. You can find the code snippet for reference here:
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 ) {
if(xmlhttp.status == 200){
var ur="https://facebook.com/344128252278047";
var res= JSON.parse(xmlhttp.responseText);
console.log(res);
document.getElementById("myDiv").innerHTML=res.cover;
}
else if(xmlhttp.status == 400) {
alert('There was an error 400')
}
else {
alert('something else other than 200 was returned')
}