I am trying to send emails to certain people depending on the button that is chosen, the table in the interface consists of two fields, the name of the person and the button that is going to send the mail when you click.
This table is built by means of a loop from an array extracted from a database previously containing the ids of the people.
echo '<legend>Enviar correos</legend>';
echo '<table>';
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo '<td>'.ucwords(getNameEmp($row['employee'])).'</td>';
echo '<td><button type="button" class="btn btn-default" name="send" value="'.$row['employee'].'" id="send"><span class="glyphicon glyphicon-send" aria-hidden="true"></span></button></td>';
echo '</tr>';
}
echo '</table>';
And my request for ajax is this:
$("#send").click('submit',(function(e) {
e.preventDefault();
$.ajax({
url: "sendMails.php",
type: "POST",
data: {
id: $(this).val()
},
success: function(result) {
alert('ok');
},
error: function(result) {
alert('error');
}
});
}));
My question is, what is the best way to know which button was selected to know which person has to send the mail?