autocomplete on every key press will most likely cause problems. You would normally only call the
autocomplete function once:
var comunidades = [
If that doesn't work, then you'll need to tell us which autocomplete library you're using.
$(document).ready(...) is deprecated:
jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:
$( handler )
$( document ).ready( handler )
$( "document" ).ready( handler )
$( "img" ).ready( handler )
$().ready( handler )
As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."