Receive data sent by AJAX to Controller

0

Hello good afternoon, I have a problem getting data sent by AJAX to a Controller

Data sent by AJAX

var txtDateInicio = document.getElementById('date_inicio').value;
var txtDateFin = document.getElementById('date_fin').value;
var parametros = {
    "txtDateInicio" : txtDateInicio,
    "txtDateFin" : txtDateFin
};

$.ajax({
    url : url,
    type: "POST",
    data: parametros,
    success: function(data) {
        window.location.href = "<?php echo base_url('index.php/login_controller/perfil_calls')?>";
    },
    error: function (jqXHR, textStatus, errorThrown) {
        alert('Error al filtrar');
    }
});

I want to get them my Controller

public function perfil_calls() {

}

I hope you can help me.

Thanks

    
asked by Javier fr 09.07.2018 в 23:59
source

1 answer

0

When you call the function with POST you receive it normally as if it were a form with tag of method='post' , then your code in the controller would be the following:

public function perfil_calls() {
    $dateInicio = $this->input->post('txtDateInicio');
    $dateFin = $this->input->post('txtDateFin');
}

For more information, an answer from SO:

  

link

    
answered by 10.07.2018 в 00:23