I am working with the open graph API and trying to run a each loop through a results callback.
I need to know when the loop is complete so I can run a ‘success’ function.
I thought it would be as easy as comparing the results length against the index but I am having no luck.
What is the best way to do this?
function authSuccess() {
FB.api('/me/friends', function (result) {
if (result.data) {
var l = result.data.length;
$.each(result.data, function (index, friend) {
if(l > index ){
//do stuff
}else{
//go to success
}
});
} else { }
});
}
Thanks for the help
This ought to do it: