Why is my .blur() code only working on second blur?
<p>I have an input, when the user enters something, my script sends the info over to a php script, which returns whether or not the entered text can be used.</p>

<p>If the text can not be used, it disables the submit button and adds a class to the reult text.</p>

<p>The problem  have is strange, the ajax works, the result is returned, but the button disabling and adding of the class doesn't happen unless you focus and blur the input a second time.</p>

<p>Here is my code:</p>

<pre><code>$('#alias').blur(function() {
if ($('#alias').val()) {
    var aliascheck = $('#alias').val();
    $(".aliascheck").load('checkalias.php?alias='+aliascheck);

    var result = $('.aliascheck').text();
    if (result.indexOf("Taken") != -1) {
        $('#shorten').attr("disabled","disabled");
        $('.aliascheck').addClass('error');
    } else {
        $('#shorten').removeAttr("disabled");
        $('.aliascheck').removeClass('error');
    }
}
});
</code></pre>

<p>The code is live here: <a href="http://markhenderson.ws/dev/tmtmu/" rel="nofollow">http://markhenderson.ws/dev/tmtmu/</a>
To replicate the "taken" event, enter "taken" as the alias. Any thing else will return available.</p>

<p>Does anyone know why this is happening?</p>

<p>Thanks</p>
