I’m having trouble understanding how to process the response when you make an API call to facebook. Should mention that I’m new to javascript.
Say I want to get the mutual friends between me and some user, and then write it to a text box. I took a shot and ended up with this …which failed. I’m pretty sure it’s because I didn’t parse the response, but I can’t figure out how. I’ve seen something like query.wait(function(rows){ for FQL queries … but I don’t know what that means..so I skipped it.
function getMutual(){
FB.api('/me/mutualfriends/'+target, function(response) {
document.getElementById('debug').innerHTML =
'FQL Information: '+ response +"<br />";
});
}
In the beginning of your callback function
function(response) {, do either adebugger;statement to start debugging in your browser, or you can do aconsole.dir(response);to see the object structure. Half your battle learning javascript is learning how to use some powerful tools that modern browsers now have built in.