My PHP code is returning JSON data for jQuery autocomplete, but autocomplete doesn't work
Jquery autocomplete
$("input#txtaddkey").autocomplete({ source: "keyword.php", minLength: 2 });
Php code
$fetch = mysql_query("SELECT * FROM o_keyword where keyword like '%" . $query . "%'"); while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) { $row_array['id'] = $row['id']; $row_array['keyword'] = $row['keyword']; array_push($return_arr,$row_array); } echo json_encode($return_arr);
JSON data output
[{"id":"2","keyword":"Games"},{"id":"3","keyword":"Goa"}]
And when typing "Ga", I get an empty li tag at the front end.
json jquery php jquery-autocomplete
Elankeeran
source share