3
I have this class, but every time I ask, and access the value of fb_firstName
is 'Undefined'. What I’m doing wrong?
inside the set method, setFb_firstName(firstName)
the value is correct, but when returning with getFb_firstName()
has no value.
function User(sender) {
var fb_firstName;
FB.api('/' + sender, 'get', {access_token: token.getPage_acess_token()}, function (response) {
setFb_firstName(response.first_name);
});
function setFb_firstName(firstName) {
fb_firstName = firstName;
}
;
this.getFb_firstName = function () {
return fb_firstName;
};
}
was with this same problem here, I solved mine otherwise because it was something else, but I saw this solution here: (http://www.w3schools.com/js/js_scope.asp), is in English but to simplify, where you have
var fb_firstname
declare asfb_firstName = '';
that should work– Armando Marques Sobrinho
Hasn’t worked yet
– Thiago R.