[eluser]bartgrrr[/eluser]
Hi,
I have a JQuery autocomplete field that needs to be filled with some content of a MySQL database.
I'm unable to read the input of the user. This input is the argument of my select statement in order to narrow down the results.
1. My form contains:
Code:
<?=form_input(array('name' => 'zipcodecity', 'id' => 'zipcodecity', 'class' => 'tb', 'value' => set_value('zipcodecity')))?>
resulting in:
Code:
<input type="text" class="tb ui-autocomplete-input" id="zipcodecity" value="" name="zipcodecity" autocomplete="off">
2. My Jquery autocomplete stuff:
$("#zipcodecity").autocomplete( { source: 'berekenen/zipcodeCityPicker' } );
3. My Controller contains:
Code:
public function zipcodeCityPicker()
{
log_message('debug', 'Controller::Berekenen::zipcodeCityPicker()');
$this->load->model('zipcode');
$val = $this->input->post('zipcodecity');
//$val = 2880;
//$val = 'bo';
if(is_numeric($val)) {
$this->zipcode->get_zipcode_city_by_zipcode($val);
} else {
$this->zipcode->get_zipcode_city_by_city($val);
}
}
If I use 2880 as argument value, I get a an autocomplete list of all zipcodes containing 2880. If I use 'bo' as argument value, I get an autocomplete list of all cities containing 'bo'.
I conclude there are no problems on data access / filling the autocomplete list.
I conclude there's a problem on retrieving the filled in characters, so there's a problem on getting the values from POST.
HOWEVER:
In the index method (of the same controller) EVERYTHING WORKS JUST FINE. code fragment of index method:
Code:
public function index()
{
log_message('debug', 'Controller::Berekenen::index()');
$this->load->model('pensioensparen');
$this->data['products'] = $this->pensioensparen->getProducts();
if ($this->form_validation->run('module_berekenen') == FALSE)
{
$this->template->write_view('content', 'pages/berekenen_view', $this->data);
}
else
{
// common
$common['zipcodecity'] = $this->input->post('zipcodecity');
...
}
}
4. My .htaccess file rewrite stuff:
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
I use CodeIgniter 2.1.2, Wamp 2.2 (Apache 2.2.22 and PHP 5.4.3), JQuery 1.9.1, JQuery 1.10.1