0
I have a form that is sent via POST as JSON. But I have an object array called classes[] in Javascript. The Object contains discilpin, ch and stroke. That is, the array that is generated dynamically is something like:
aulas[{"disciplina":"1","curso":"1","ch":"1"},{"disciplina":"2","curso":"2","ch":"2"}]
I used serialize() to generate the JSON of the form, but how do I pass this array in that same JSON so that I can access the data, in php, in the same way as access with the result of serialize().
I tried using stringify, but it doesn’t have a reference like the other form fields.
$.ajax({
type: "POST",
data: $('#form').serialize()+JSON.stringify(aulas),
url: "includes/post.php",
success: function(msg){
//teste
}
});
But how do I get this data in php this way? If I pass the form I can get it with $_POST["fieldDoForm"]. This way it generates only the reference of the form and classes. How I would have to do to get only certain field within the form I passed?
– Sobotyk
I made changes to the answer. See if it helps you.
– bio
That msmo bro. Helped me peaceful. Thanks :D
– Sobotyk