Exec JS after flag ajax result In my portal I need to use "flags" module to create a simil twitter "follow/unfollow". I have installed and configurated this module. All works, via AJAX too. 

Now I need to exec some other JS function after that the flag module has completed his call. I think that I need to add (on the backend) some "commands" before flags return "commands" to execute in the frontend. 

How I can I do this ? 

Thanks, M.
here is API https://www.drupal.org/node/336122

The two events

The flagGlobalAfterLinkUpdate event

This event is triggered immediately after a flag link has been updated. (Flag links appear in two flavors: "Bookmark this!" and "Unbookmark this!", and when we speak of "update" we mean this change in appearance).

The flagGlobalBeforeLinkUpdate event

This event is triggered just before a flag link is updated. As will be explained later, the existence of this event is for cosmetic reasons only: it allows us to carry out actions while the throbber () is still visible.

$(document).bind('flagGlobalAfterLinkUpdate', function(event, data) {
  alert('Object #' + data.contentId + ' (of type ' +
    data.contentType + ') has been ' + data.flagStatus +
    ' using flag "' + data.flagName + '"');
});