1
I have this form:
<form>
<select name="data">
<option>0831</option>
<option selected>4731</option>
<option>9831</option>
</select>
<br />
<input type="text" name="telefone[0].numero" placeholder="Telefone"> <br />
<input type="text" name="telefone[0].operadora" placeholder="Telefone"> <br />
<input type="text" name="telefone[0].contato" placeholder="Telefone"> <br />
<input type="text" name="telefone[1].numero" placeholder="Telefone"> <br />
<input type="text" name="telefone[1].operadora" placeholder="Telefone"> <br />
<input type="text" name="telefone[1].contato" placeholder="Telefone"> <br />
<input type="text" name="endereco[]" placeholder="Endereço"> <br />
<input type="text" name="endereco[]" placeholder="Endereço"> <br />
<input type="text" name="endereco[]" placeholder="Endereço"> <br />
<input type="text" name="nome" placeholder="Nome">
</form>
I’m picking him up serialize:
$(document).ready(function(){
var form = $('form').serialize();
$.ajax({
url: 'index_server.php',
type: 'POST',
data: form,
success: function(callback){
console.log(callback);
}
});
})
The problem is that with the serialize it does not send correctly to PHP by giving a print_r()
in PHP it returns:
Array
(
[data] => 4731
[telefone] => Array
(
[0] =>
[1] =>
)
[endereco] => Array
(
[0] =>
[1] =>
[2] =>
)
[nome] =>
)
I needed it to take all the form data correctly. The problem is only one that is an array and contains the property numero, operadora e contato
, i.e., the telephone.
Thanks, solved
– Alisson Acioli