jquery autocomplete not working with JSON data

☆樱花仙子☆ 提交于 2019-11-28 00:03:58

From:

your JSON needs to contain label or value (or both). Change keyword to value and it should work fine.

Your code needs to be slightly modified.

 while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
    $row_array['value'] = $row['id'];
    $row_array['label'] = $row['keyword'];

    array_push($return_arr,$row_array);
}

echo json_encode($return_arr);

Now your json format will be

[{"value":"2","label":"Games"},{"value":"3","label":"Goa"}]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!