JQuery simple search
<p>I attempting to write a simple JQuery search.</p>

<p>This is what I have so far:</p>

<pre><code> $(document).ready(function(){
$("#search").bind("keydown", function() {
    if($("#search").val() != ''){
        $.get("/search", {phrase: $("#search").val()}, function(data) {
            $("#searchResults").html(data);
        });
    }else{
        $("#searchResults").html('');
    }

});
 });
</code></pre>

<p>The problem I am having is that when I press down a key the first letter is not sent to the server.  In addition, I have to hit backspace twice before the searchResults are cleared.</p>

<p>I have been using Firefox to observer the get requests.</p>

<p>For example, I press the key "f" and the phrase value passed via the get request is blank.  If I press "ff" then only "f" is sent via the get request.  I have to press backspace twice before the searchResults are cleared.</p>

<p>Does anyone know what the problem is or how I can change this to avoid this problem?</p>

<p>Thank you,</p>

<p>Brian</p>
