I'm having some problems solving this situation. I'm trying to pass my array of objects via AJAX to another page in PHP and read the properties that are inside each object within that array. For you to try to understand better I will post the code here ...
My JavaScript is assembling the object and returning this data (example values):
[{"horario":"14:00","id_bus_rota_parada":"1","id_bus_rota":"0","id_bus_parada":"22"},{"horario":"15:00","id_bus_rota_parada":"1","id_bus_rota":"0","id_bus_parada":"23"}];
These objects are inside the array "data []" ...
So I try to pass this array of objects to PHP already transformed into JSON.
$.ajax({
url: "../actions/rota_inserir.php",
type: "post",
contentType: 'application/json',
data: JSON.stringify(dados),
dataType: 'json',
success: function (data) {
if (data.sucesso == true) {
var n = noty({
text: "Rota cadastrada com sucesso!",
type: 'success'
});
}
},
});
Now I do not know how to get this data in PHP, I made a line of code but it did not work ...
$horarioParada = $_POST['horario'];