2
I have the following object:
var pessoas = [];
pessoas = {
nome: "julio",
sobrenome: "Henrique",
idade: 18,
amigos : ["Pedro", "João", "Isabella"]
}
I send the friends array via ajax like this:
$.ajax({
url:'retira_falsos_amigos.php',
type: "post",
data: { amigos: pessoas.amigos },
complete: function (response) {
$('#output').html(response.amigosVerdadeiros);
},
error: function () {
$('#output').html('Bummer: there was an error!');
},
});
and makes no mistake.
But in my code, the array amigos
turns an array of objects and making the same request results in error.
when it turns an array of objects looks like this:
itensAmigos[0] = {
name: data[0][0],
intervalo: intervalo,
Start: Date.UTC(ano,mes,dia,hora,minuto),
data: data[0][1],
tooltip: {
valueSuffix: " -"
}
};
pessoas = {
nome: "julio",
sobrenome: "Henrique",
idade: 18,
amigos : itensAmigos
}
This is the error that appears:
I didn’t quite understand the problem. Could put the snippet of the PHP code where you handle the received data and which error is appearing?
– Wallace Maxters
I supplemented my question with error, but the error that appears does not make sense with my code
– Julio Henrique
I found the solution, if I was sending an array() I must inform that the variable that will carry the data tbm is an array, hence the need for by date: { 'friends[]': people.friends }, in quotation marks. after that no more error
– Julio Henrique