jason
jason

Reputation: 7164

Display message when JavaScript function works

I want to display a message when this function works :

  function testAPI() {
    FB.login(function(){
    FB.api('/me/feed', 'post', {message: 'Hello World'});
    }, {scope: 'publish_actions'});

My attempt was this and it didn't work :

  function testAPI() {
   FB.login(function(response){
    FB.api('/me/feed', 'post', {message: 'Hello World'});
    }, {scope: 'publish_actions'},{complete(response);});
  }

I'm getting this error :

Uncaught SyntaxError: Unexpected token var

How can I make this work? Thanks.

Upvotes: 0

Views: 112

Answers (1)

tweeper
tweeper

Reputation: 352

You are using Facebook API?if yes ,then Fb.login function may be having below signature

FB.login(parameter1,[parameter2,..],function(response){
    //do something with the response
});

you are declaring a new variable where you should be passing parameter an specify callback funtion.you should specify parameters required by the api and then in the callback function that you specify you could display whatever message you want.

Upvotes: 1

Related Questions