Modal dialog and autocomplete
I want to use dialog box, and autocomplete in it, but i have problem. Mainly in autocomplete I hope ;)
![](http://forum.jquery.com/viewImage.do?fileId=14737000001105591&forumGroupId=14737000000003003)
The "Pole" value is select input with names of columns in my DB table. The "Wartość" is of course the searching value.
I dont know exacly how to transfer the values to the PHP script.
The JS behind:
- $s("#clientSvalue").autocomplete({
source: function(request, response) {
$s.ajax({
url: baseURL+"client/findClient/"+$s("#clientStype")+"/"+$s("#clientSvalue"),
dataType: "jsonp",
success: function(data) {
alert("success-test");
response($s.map(data.geonames, function(item) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name
}
}))
},
error: function(data) {
alert("error-test");
}
})
},
minLength: 2
});
And the PHP script
- public function findClient($type, $value)
{
//if( request::is_ajax() )
//{
$this->auto_render = false;
$owners = ORM::factory('owner')
->where('station_id', $this->session->get('user')->station_id)
->like($type, $value)
->find_all();
$json = array();
foreach($owners as $owner)
{
$json[] = $owner->as_array();
}
//echo Kohana::debug( $json );
echo '{"geonames": '.json_encode( $json ).'}';
//echo json_encode($json);
//}
}
What's I'm doing wrong?