1

This seems in my head like it should work but I cant figure out why it doesn't:

(function ($) {

$.fn.extend({

    facebook: function (opts, callbackFnk) {

        var $this = this;
        ...
        ...
        ...

        $this.fbGetFriends = function( clback ){
            jsonUrl = fbMe + '/friends?access_token=' + token + '&callback=?';
            $.getJSON( jsonUrl, function( json ){
                console.log(json.data[0].name);
                clback.call(json);
            }); 
        }
        ...
        ...
        ...

In the console log the first name appears

In my other script:

var facebook = $.fn.facebook(
    { 
        myClientId  : '###############', 
        mySecret    : '##############' 
    }
);

facebook.fbOnLogin = function(){
    user = facebook.userDetails();
    token = facebook.getToken();
    facebook.fbGetFriends(function( json ){
        for ( var i in json ) {
            console.log( 'friends: ' + i + ' ' + json[i] );
        }
    });
}

In console log im getting nothing displayed and in previous tests its displaying errors data undefined.

Can anyone tell me where im going wrong?

regards

2
  • @Kolink has answered the question, but is there a reason why you're adding this Facebook library to jQuery.fn? It should be a lot less complicated if you make it separate... Commented Apr 5, 2012 at 8:56
  • It's a whole plugin for android/phonegap which actually works. I have already tried the below but will try again. Commented Apr 5, 2012 at 9:03

1 Answer 1

3

You don't need clback.call, just clback(json) is enough.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.