I’ve been pulling my hair out with this function. It’s a function within a function which is why I think it’s not returning anything, heres the code:
function getEventImageNormal(data) {
$.getJSON("https://graph.facebook.com/fql?access_token=" + access_token + "&q=SELECT pic FROM event WHERE eid=" + data, function(data){
console.log(data.data[0].pic);
return data.data[0].pic;
});
}
The correct item, the URL of the image, is being set to the console log, but not being returned?
If anyone is wondering why I’m not using https://graph.facebook.com/object_id/picture to get the events image, it’s because this functionality is currently not working and the only method is to use FQL for event images.
You need to add
callback=?parameter to your url to let remote url and jQuery know it is ajsonpcall. If it is only json sent, it is against cross domain security policies and browser won’t accept it into the DOM.This is in addition to processing the data within the sucecss callback of request, due to asynchronous nature of ajax.