How to use Jquery/AJAX to fetch data from the server-side with CodeIgniter
16:18 13 Oct 2016

I have this form

Actualizar Precios'; ?>

and then this Jquery function:

$(document).ready(function(){
    $("#enviar").click(function(event){    
        event.preventDefault();
        
        var actualPorcentaje = $('#actualPorcentaje').val();
        
        $.ajax({
            type: "POST",
            data: $('#formProductos').serialize(),
            url: "index.php/actualizacion/adicionar",
            dataType: 'json',
            success: function(data)
            {
                if (data.result == true) {
                    $('.results').html(data);
                } else {
                    alert('Ocurrió un error al agregar un producto.');
                }
            }
        });
    });
});

redirected page have this function

function gerenciar()
{
    // ... 
    $config['base_url'] = base_url() . 'index.php/actualizacion/gerenciar/';
    $config['total_rows'] = $this->actualizacion_model->count('actualprecios');
    // ...
    $this->pagination->initialize($config);     
    $this->data['results'] = $this->actualizacion_model->get('actualprecios', 'idActualizacion, actualPorcentaje, actualFecha', '', $config['per_page'], $this->uri->segment(3));
            
    $this->data['view'] = 'actualizacionp/actualizacion';
}

and "actualizacion_model.php have this function

function get($table, $fields, $where = '', $perpage = 0, $start = 0, $one = false, $array = 'array')
{
    $this->db->select($fields . ',marcas.marcaNombre');
    $this->db->from($table);
    $this->db->join('marcas', 'marcas.idMarca = actualprecios.marcaid');
    $this->db->limit($perpage, $start);
    $this->db->order_by('idActualizacion', 'desc');
    if ($where) {
        $this->db->where($where);
    }
        
    $query = $this->db->get();
    $result = !$one ? $query->result() : $query->row();
    return $result;
}

But it's not working, "porcentaje" is 0.

php jquery ajax codeigniter model-view-controller