Always the following code to send and receive data from a form, first I group them in formData and then in php I take them out one by one to know their value, however I have several selects and only take the last value (or be the last element selected), does anyone know how I can know all the values in the php?
Jquery:
function savepar(idForm){
var formData = $("#"+idForm).serialize();
$.ajax({
data: { data:formData },
type: "POST",
url: "include/q_setData.php",
success: function(data) {
alert(data);
}
});
return false;
}
PHP:
parse_str($_POST['data'], $searcharray);
foreach($searcharray as $nombre_campo => $valor){
$asignacion = "\$" . $nombre_campo . "='" . $valor . "';";
eval($asignacion);
echo $asignacion." "."<br>";
}