I’m trying to implement the jQuery autocomplete.
The autocomplete call takes 500ms to load the list. During those 500ms, if user types more characters, the autocomplete fires again, resulting in duplicate listings.
How can I limit the call to only happen once?
–
On the Javascript side:
$(document).ready(function(){
var url = "localhost/index.php?page=user&choice=getlist";
$("#list").autocomplete({json_url:url,height:6});
});
On the PHP side:
$arr[] = array(//filled with array data );
print json_encode($arr);
Turns out that I just had to move a parameter ‘json_cache’ in the .js file outside of the callback function to fix this problem.