2
I have a code that I pick up with PHP the students registered in my bank, and I do a for so it has 1 form for each student. Each form has its Submit button, which takes it to AJAX to serialize the form.
This is the tag of my form (which is inside the for
of PHP)
<form method="post" enctype="multipart/form-data" action="#" id="form1" class="form">
The Shadow of it
<button onclick="saveAluno(); return false" class="btn btn-block btn-primary">
and this is my AJAX to serialize
function saveAluno(){
var data1 = $('.form').serialize();
console.log(data1);
$.post("controller/setters/addAlunoRotina.php", $('#form1').serialize(), function (response) {
alert("Salvo com sucesso!");
}); }
This way he is Serializing all the Foms together, at once. Is there any way I can serialize one by one of these Foms?
This is an image of the Foms of my system, so maybe it will be easier to understand the problem;
Is there a need to be a form for each student? I think the correct thing in this case is to use only one form for everyone, because you are treating the same student "object". If you are dealing with different objects/themes, then it makes sense to have more than one form.
– Edson Horacio Junior
@Edsonhoraciojunior unfortunately, there is the need yes Edson.
– Luan Gabriel
In ajax you want to send only one form?
– Edson Horacio Junior
@Edsonhoraciojunior this Edson, each of the Forms has its send button, I want to click it to serialize only the button form. I will edit my post;
– Luan Gabriel
Pera. You want to have, for example, 4 forms and by clicking "Save" send only the respective data of that form (ie only one)?
– Inkeliz
That’s right @Inkeliz
– Luan Gabriel