Check if function is complete in function that is triggered by unrelated event in javascript
<p>I have a function called call facebook.</p>

<pre><code>call_facebook(284328420994");
call_facebook(197214710347172);
</code></pre>

<p>It runs severaltimes It makes an ajax request to facebook and often takes a few seconds to complete.</p>

<p>I have an other function that modifies the html when I click a marker on a google map:</p>

<pre><code>google.maps.event.addListener(loc, 'click', function () {
    var template = $('#trips').html();
    var content = locationIndex[loc.title];
    var html = Mustache.to_html(template,  content );
});
</code></pre>

<p>If one of the markers are clicked and then a call_facebook-event is completed. I want to rerun the function that get's triggered when you click the marker. What is the best way to do this?</p>
