0
At the moment I am sending the entire form, I need to send only one field of html by ajax, Idaparelho is dynamic and comes from the database follows my ajax code and the field I need to send:
AJAX
$(function () {
$("#visualizarAparelhos").submit(function (e) {
e.preventDefault();
var FormData = $("#visualizarAparelhos").serialize();
$.ajax({
type: "POST",
url: "administrador.php",
data: FormData
}).done(function (data) {
console.log(data);
});
return false;
alert("Não enviou!!!");
});
});
FIELD TO BE SENT :
print "<td><button id='IdAparelho' value='".$id."' type='submit' class='btn btn-primary' data-toggle='modal' data-target='#modalVisualizarComponentes'>".$id."</button></td>";
Roberto, this "id" that you are using, is being the same for each line ? type, you have several Uttons with id='Idaparelho' and only changes the value ?
– Lucas Queiroz Ribeiro
No, this id is dynamic, it comes from the database, I just want to get the value of the button I press.
– Roberto Albino
right, then you won’t have another element with the same
id ='IdAparelho'
? I ask this because it is a common mistake to create several lines changing only the value and keeping all id equal (which does not work because ids need to be unique)– Lucas Queiroz Ribeiro
Actually Lucas, I hadn’t thought about it, I get your logic, I’ll sort that question out too, I’ll do Idaparelho+$Id
– Roberto Albino
@Robertoalbino saw my answer?
– Guilherme Nascimento