Send checkbox as fix in ajax and process it codeigniter

1

My problem is that when sending the array with the selected checkboxes, the empty variable is received in my controller. For example, I have:

<input type='checkbox' name='valores[]' value='1' />
<input type='checkbox' name='valores[]' value='2' />
<input type='checkbox' name='valores[]' value='3' />
<input type='checkbox' name='valores[]' value='4' />

and to send it by ajax I do the following:

$.ajax({
        url:$("form").attr("action"),
        type: $("form").attr("method"),
        data:$("form").serialize(),
success:function(respuesta)
        {
        alert('Perfil creado con éxito');
        }

and in my controller I receive it in the following way:

$ids = $this->input->post('valores');

I have taken 'values' in an alert and it prints something like this: values% 5B% 5D = 1 & values% 5B% 5D = 2

Someone can tell me what I'm doing wrong, or how I can receive this data in an appropriate way to process it.

    
asked by CLAUDIA YOANA IBANEZ SANTA 01.12.2016 в 19:07
source

1 answer

0

Try using $.param(data) to send the form data.

    
answered by 01.12.2016 в 19:35