I am sending data from a form which has many checkboxes that share the same name, I want to send those values, I do it in the following way:
var dataform= ($('input[name="cnSelects"]:checked').serialize());
$.ajax({
data: {"data":dataform},
type: "POST",
url: "asset/query/q_showfieldstomake.php",
success: function (data)
{
alert(data);
}
});
and when I receive them they arrive like this:
'cnSelects=name-c-cn&cnSelects=lname1-c-cn&cnSelects=lname2-c-cn&cnSelects=fnacimiento-c-cn&cnSelects=telfijo-c-cn&cnSelects=telmovil-c-cn&cnSelects=email-c-cn&cnSelects=otraact-c-cn&cnSelects=cualotraact-c-cn'
How do I do php to "deSerialziarlo", I've always used this function:
parse_str($_POST['data'], $searcharray);
foreach($searcharray as $nombre_campo => $valor){
$asignacion = "\$" . $nombre_campo . "='" . $valor . "';";
eval($asignacion);
echo $asignacion." "."<br>";
}
//esta funcion hace que cada name del formulario se combierta en una variable con su respectivo valor
}
but here it does not work because all the data comes with the same name. and I want to have each value independently.