I was wondering how I would be able to get this working? I’ve read the demo files, but I’m curious if there is a way to make it work like this. I’ve got one php file that is something like this
$query = "SELECT DISTINCT City FROM Locations ORDER BY City";
foreach($DBH->query($query) as $row)
{
$array[] = $row['City'];
}
echo json_encode($array);
and some js
$('.searchbox').autocomplete('test.php', {minChars: 3,});
When I test it, I type in three letters, and instead of suggestions, I get the whole json array. I know that it’s possible for this jquery-autocomplete to work with local data, but I just don’t know how. https://github.com/dyve/jquery-autocomplete/ is the source, by the way.
The docs say you should set a
remoteDataTypeoption whose value isjsonif your backend is returning a JSON Array:E.g.
Also, your server-side query should make use of the
qparameter that the autocompleter sends in theGETto only return the results that match what has been typed in.