Javascript wrong alert order
<p>I have a javascript call like this:</p>

<pre><code>usernameTest('queijo');
alert('a');
</code></pre>

<p>The function <code>usernameTest()</code> is working and, for debugging, it alerts the string "t" or "f".</p>

<p>Why, when I load this page, the first alert shown is "a" and only after "t" or "f"? (Btw, jQuery is loaded into the page too.)</p>

<p>[EDIT]</p>

<p>Source Code:</p>

<pre><code>function usernameTest(username) {
    var unReg = /^[0-9a-zA-Z_]{1,20}$/;
    if(!unReg.test(username))
        return false;
    $.ajax({
        type : 'POST',
        url : 'checkuser.php',
        data : 'username=' + username,
        cache : false,
        success : function(response) {
            if(response == 1) {
                alert('f');
                return false;
            } else {
                alert('t');
                return true;
            }
        }
    });
}
</code></pre>

<p>[EDIT2]</p>

<p>I already know the problem is that is calls AJAX. The new main question is now another.
I'm calling it like that (in the proper place, not the code for debugging);</p>

<pre><code>if(!usernameTest(argument))
    //do something
</code></pre>

<p>How can I do something like this?</p>
