Starting jQuery autocomplete immediately after my Ajax call to server
<p>In my code I bind a <code>keyup</code> event to my input to check if the input value's length is 3.
If it is, I make an Ajax call to the server getting the records from my database which start with these 3 character entered and then I start jQuery autocomplete with source - the data from database.</p>

<p>The problem is when the user enters three characters, I get the source for the autocomlete and only when he enters the fourth character the autocomplete starts. Is it possible to change that behaviour and as soon you enter 3 characters and get the source to start autocomplete?</p>

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

<pre><code>var keypresshandler = function () {
        var  strin = document.getElementById('txtInput').value;
        newstr = strin.replace(/[^\u0400-\u04FF0-9]/gi, '');
        if (newstr.length&lt;3)
        {
                $( "#txtInput" ).autocomplete( "destroy" );
        }  else     
            if (newstr.length==3)
            {   
                 triming();    
            }
    }


    $(function() {    
         $('#txtInput').bind('keyup', keypresshandler);
     });

    function triming() {
         //make asynchronous ajax call to server to get the source of my autocomplete                    
         // alert (mec.length);       
         $( "#txtInput" ).autocomplete({source: mec});
     }

   }
</code></pre>
