Send and receive array via jQuery

1

I can not send and read an array via jQuery, could you help me? My submission looks like this:

var tipoAtividade = $('#arrayTipoAtividade:checked').serialize();

The activity type variable is receiving this data:

tipo_atividade%5B%5D=AGUA&tipo_atividade%5B%5D=ALMOCO

How do I read this variable, type when I use a foreach to read a php array?

    
asked by anonymous 10.03.2017 / 13:51

2 answers

0

PHP will receive this data and save it to a vector, see example:

<?php
$tipo_atividade = $_GET['tipo_atividade'];
foreach($tipo_atividade as $tipo){
    echo($tipo . '<br>');
}
?>
    
10.03.2017 / 14:19
0

These strange characters are [] referring to the html array. Please try submitting this data for post instead of get , but please add more information anyway so we can help you.

    
10.03.2017 / 15:16