Javascript async callback
<p>My problem is better explained in code:</p>

<pre><code>//This code is triggered before ajax ObBegin. But I need f1 to return a boolean to either cancel or continue the event.
f1();

function f1(){
    $.modalWindow.Open(); //This is an async method, this is where my problem lies.
    //I need to freeze here and wait on a return value from one of the events below.
}

//In the modal window:

//An event which waits for the click event
$('.cancelBtn').click(function(){
    //How do I send false back to f1?
    closeModalWindow();
});

$('.yesBtn').click(function(){
    //How do I send true back to f1?
    closeModalWindow();
});
</code></pre>

<p>So basically what happens is this:</p>

<ol>
<li><code>openModalWindow()</code> opens a modal window that waits on a button click.</li>
<li>I want to pass the value back to f1 and return it.</li>
</ol>

<p>Is there a way to fix this?</p>
