When I try to make an ajax request to a codeigniter route I get an 404 error
The root folder of the project is http://localhost/control_cuotas/
this is the controller(index works):
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Control_cuotas_controller extends CI_Controller {
public function index()
{
$data = array();
$tables = $this->getTables();
$data['tables'] = $tables;
$this->load->view('main/main_view', $data);
}
public function getData($data){
var_dump($data);
}
private function getTables(){
$sql = "SELECT TABLE_NAME "
."FROM INFORMATION_SCHEMA.TABLES "
."WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME LIKE 'datos_%'";
$query = $this->db->query($sql);
$tables = array();
foreach ($query->result() as $row){
$name = substr($row->TABLE_NAME,0,-2);
if(!in_array($name,$tables)){
array_push($tables, $name);
}
}
return $tables;
}
and this is the javascript:
$(document).ready(function(){
$('#tables').change(function(){
var selected = $(this).val();
$.ajax({
url:'getData/'+selected
});
});
});
}
an this is the route
$route['getData/(:any)']['GET'] = 'control_cuotas_controller/getData/$1';
The request is done on the following url
http://localhost/control_cuotas/getData/selected_value