Render a list once it is avaialable
Hi ,
I am trying to make simple JQuery application with Auto complete .
I need when the user types each character --> go to server and do some logic there -->then render a list from the server .
I succeeded to do that .However, the only thing that BUGS me that once the response comes from the server , I must type another character in order to be able to render the list .
How could I render the list whenever it comes from the server without the need to type any thing .
- $(document).ready(function() {
- $('#autocomplete').keydown(function() {
- if ($('#autocomplete').val()) {
- $.getJSON("../x/foo", { name: $('#autocomplete').val()}, function(result) {
- $("input#autocomplete").autocomplete({source:result.fooList});
- });
- }
- });
- });
- <input id="autocomplete" />