hi .
Have problems with autocomplete.
- my code:
- $(".autCpltSearch").autocomplete({
source:' <?php echo Yii::app()->createUrl('casa/AutocompleteSearch') ?>',
minLength: 1
});
this is the php:
- $res = array();
$term = Yii::app()->getRequest()->getParam('term', false);
if ($term)
{
// test table is for the sake of this example
$sql = 'SELECT localidade FROM casa where LCASE(localidade) LIKE :name';
$cmd = Yii::app()->db->createCommand($sql);
$cmd->bindValue(":name","%".strtolower($term)."%", PDO::PARAM_STR);
$res = $cmd->queryAll();
}
echo CJSON::encode($res);
Yii::app()->end();
}
this is returning
[{"localidade":"faro"},{"localidade":"Altura"}]
it's ok , but can't see the results in autocomplete.
thanks.