Facebook integration with javascript FB Graph api Post on wall Unknown error in firefox

0

I am posting on the user`s wall using the FB Graph api my function to post on wall is as follow:

 function PostToWall()
 {

      var mymessage = 'my message';
      var mypic = 'http://myapp/a.jpg';
      var mylink = 'http://www.myapp.com';
      var myname = 'myApp';
      var mydesc = 'my desc .';
      FB.api('/me/feed', 'post', { message: mymessage, picture: mypic, link: mylink, name: myname, description: mydesc }, function (response) {
            if (!response || response.error) {
                       alert(response.error.message);
            } else {
                        alert('Post ID: ' + response.id);
             }
      });
      // alert('Do you want to continue ? ');
 };

it works fine in crome but when i use the same in firefox it prompts Unknown error from alert(response.error.message); .and in the error console of firefox error is

Error: uncaught exception: [Exception... "prompt aborted by user"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: resource://gre/components/nsPrompter.js :: openTabPrompt :: line 468"  data: no]

I found the solution is the prompt user before the end of the function see the last line alert('Do you want to continue ? '); . When i write this alert it works fine in firefox also but i do not want to promt user for any message. what could be the problem and what would be the solution ?

I am using firefox 5.0 . and my operating system is windows 7.

PostOnWall function is called from another function which is as follow:

function f(){

     PostToWall();
    ...
    ...
    //code to click a submit button
}
javascript
windows
firefox
facebook-graph-api
jakarta-ee
asked on Stack Overflow Jun 4, 2012 by Hemant Metalia • edited Jun 6, 2012 by Hemant Metalia

1 Answer

3

I have written code to click a submit button in a callback handler as follow:

function PostToWallCallBackHandler(response) {
     if (!response || response.error) {
         alert(response.error.message);
     } else {
          document.getElementById('fbSubmit').click();
     }
 }
 function PostToWall(mymessage,mypic,mylink,myname,mydesc,callbackHandler) {
     FB.api('/me/feed', 'post', { message: mymessage, picture: mypic, link: mylink, name: myname, description: mydesc },function (response){callbackHandler(response);} );
 };

it works fine with both crome and firefox,safari and IE 9.

answered on Stack Overflow Jun 6, 2012 by Hemant Metalia

User contributions licensed under CC BY-SA 3.0