Jquery POST and suggestion list
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/13824510/jquery-post-for-suggestion-list">Jquery POST for suggestion list</a>  </p>
</blockquote>



<p>I have the next code and it works well, the problem is that when the user finishes writing the word, the script keeps creating post calls and changing the suggestion list constantly.</p>

<p>I want to do something that if the user keeps writing a word, the script stops all the post calls to only do the last.</p>

<pre><code>$("#inputString").keydown(function() {
lookup($(this).val());
//alert('a');
});

function lookup(inputString) {
if(inputString.length == 0) {
    $('#suggestions').fadeOut(); // Hide the suggestions box
} else {
    $.post("../jsonshow.php", {q: ""+inputString+""}, function(data) { // Do an AJAX call
        $('#suggestions').fadeIn(); // Show the suggestions box
        $('#suggestions').html(data); // Fill the suggestions box
    });
}
}
</code></pre>
