Facebook graph api - why using async ajax file upload i cannot get the photo id response?

Im using the iframe techinique to upload a photo to the facebook graph api. im using this technique: http://www.openjs.com/articles/ajax/ajax_file_upload/response_data.php.

The photo gets uploaded sucessfully. But i NEED to read the response it gives to me on my iframe, but im not being able to do it. I tried every technique i know, pure javascript and jquery hacks.. but nothing works...

the format of the response is the following (i can see this on chrome js console ):

   "id": "111346062333977",
   "post_id": "100003757518505_111258412342742"

what is that format? how can i read it? its not on the DOM, its not on the body, its nowere!!!!


The response from Graph API are always JSON encoded (unless callback parameter specified, in that case it's JSONP).

You will not be able to get that response in a flow you trying to implement. If you doing direct upload of photo to Graph API from client-side response will be subject of cross-domain policy and your JavaScript simply have no access to the response.

You should upload the image from server side to be able to retrieve response which contain uploaded photo id

If I understand your problem then you came across the Same origin policy since you post the form into an iframe, and the action of the form is to another domain, different than yours (the one in which the main page is loaded from).

Because of that, the response you get in the iframe can not be then passed to the parent page since they don't share the same domain and the browser blocks the communication.

As @JuicyScripter wrote you might want to think about posting the image from the server side which will make things simpler. If how ever you don't want to give up on the client side solution so quickly, I suggest you check this thread: Facebook Graph API - upload photo using JavaScript

Need Your Help

Javascript library to create calendar uri/links to Google, Yahoo, Outlook , iCal?

calendar yahoo javascript icalendar google-calendar-api

I have seen a very specific and professional web page widget (e.g. http://whatsnextlectures-work.eventbrite.com/ and meetup.com). Please help me find the library that creates the links.