From jQuery UI site (veiw source):
$( \"#birds\" ).autocomplete({
source: \"search.php\",
minLength: 2,
select: function( event, ui ) {
log(
$( "#birds" ).autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
url:"search.php",
data: request,
success: response,
dataType: 'json'
});
}
}, {minLength: 3 });
//-------------------------
//search.php - example with request from DB
//
$link = mysql_connect($mysql_server, $mysql_login, $mysql_password)
or die("Could not connect: " . mysql_error());
mysql_select_db($mysql_database) or die("Could not select database");
mysql_set_charset('utf8');
$req = "SELECT mydata FROM $mysql_table WHERE mydata LIKE '".$_REQUEST['term']."%' ORDER BY mydata ASC";
$query = mysql_query($req);
while($row = mysql_fetch_array($query))
{
$results[] = array('label' => $row['mydata']);
}
echo json_encode($results);
?>