Skip to content

Instantly share code, notes, and snippets.

@charyorde
Created September 12, 2013 11:56
Show Gist options
  • Save charyorde/6536222 to your computer and use it in GitHub Desktop.
Save charyorde/6536222 to your computer and use it in GitHub Desktop.
Asynchronously(one after the other) execute bits of code
this.renderUI = function(res) {
var connected = (res.user != null && res.user.isConnected);
var contactsData = [];
if(connected) {
$j('#jive-modal-invite').trigger('close');
contactsData['contacts'] = gigya.socialize.getContacts({callback: function(response){ // How can I async js this line such that only when this returns should alert be called?
contactsData['contacts'] = response;
}});
alert(contactsData); // returns null
}
};
// Executing the code will return 'undefined' for contactsData.
@charyorde
Copy link
Author

gigya.socialize.getContacts({callback: function(response){
contactsData['contacts'] = response;
},
gigya.socialize.getContacts.contactsData = contactsData;
});

@charyorde
Copy link
Author

gigya.socialize.getContacts({callback: function(response){
contactsData['contacts'] = response;
}
},
gigya.socialize.getContacts.contactsData = contactsData;
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment