Call a method when another one finishes
<p>I have a function in javascript which consists of an ajax call. Let's call it search();</p>

<p>Then I have an event onKeyUp.</p>

<p>In the onKeyUp event, I have an enterPressed() function.</p>

<p>I want to call this function AFTER search() finishes.</p>

<p>I think callbacks won't help here.</p>

<p>Here's my code:</p>

<pre><code>function search () {
       ...
}

ed.onKeyUp.add(function (ed, e) {

    if (e.keyCode == 13)
                enterPressed();

}

function enterPressed() {
       ...
}
</code></pre>
