Modal dialog and autocomplete

Modal dialog and autocomplete

I want to use dialog box, and autocomplete in it, but i have problem. Mainly in autocomplete I hope ;)



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:
  1. $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
  1. 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?