What are the steps for having jQuery UI’s autocomplete use a database?
Specifically, how do I pass this script the entered value? How does autocomplete receive the script’s json?
What I know:
1) Change the ‘source option’ to a script that queries the database.
2) ?
Current code:
$("#searchInput input").autocomplete({
source: "script_that_queries_the_db.php"
});
step 2? Have your php page
mysql_querybased on$_GET['term']and return the results usingjson_encode.Edit: Also, make sure the array you pass to
json_encodeis a flat array, otherwise jQueryUI won’t read it as well as we’d like without writing more custom code.