Eric, we have two options:
Serialize fields sent from fields using field name as prefix:
Manually build array with fields sent using field name as prefix:
- WAY TO "SERIALIZE WITH A NAME PREFIX"
Be two fields with prefix "field"
<input type="text" name="campoNome">
<input type="text" name="campoEmail">
Then, we save in a variable the object containing the data of the fields:
var camposEnviados = $("input[name^='campo']").serialize();
- WAY "BUILD MANUALLY"
We can build the array manually (by selecting field by field its value):
var camposEnviados = [];
camposEnviados[0] = $('campoNome').val();
camposEnviados[1] = $('campoEmail').val();;
- SENDING VIA AJAX
$.ajax({
type: "POST",
data: {camposEnviados: camposEnviados},
url: "index.php",
success: function(msg)
{
$('.resposta').html(msg);
}
});
Hi Felipe! Your idea and explanation helped me a lot in the final assembly of the process. I chose to launch the array in input value of type 'Hidden' and at the time of Submit. Thank you so much for your help! Big hug!
– Eric Coutinho
Eric, good morning! Glad you decided! Hug
– Felipe Douradinho