Reputation: 758
I'm trying to update a local variable in a function with the returned data from a callback function. But it's looking like the callback function doesn't have access to it.
Below is what I'm working with:
this.renderUI = function(res) {
var connected = (res.user != null && res.user.isConnected);
if(connected) {
$j('#jive-modal-invite').trigger('close');
var contactsData = gigya.socialize.getContacts({callback: getContacts_callback });
console.log(contactsData);
}else {
console.log('openid disconnected');
}
};
function getContacts_callback(response) {
return response;
}
Upvotes: 1
Views: 305
Reputation: 3269
console.log(contactsData);
is being executed before your callback is complete try this:
gigya.socialize.getContacts({callback: function(response){
contactsData['contacts'] = response;
console.log(contactsData);
} });
Upvotes: 1