while($reg = $stmt->fetch(PDO::FETCH_OBJ))
{
$id = $reg->id;
echo "<div class='altpost' id='$id'></div>";
echo "<form id='$id' class='faltpost' method='post' action='altp.php'><input name='naltpost' type='number' value='$id' hidden/><button>editar</button></form>";
}
jQuery(document).ready(function(){
jQuery('.faltpost').submit( function(){
var dados = jQuery(this).serialize();
jQuery.ajax({
url: "altp.php",
type: "POST",
data: dados,
success: function(data)
{
var id = $('.altpost').attr("id");
$(document.getElementById(id)).html(data);
}
});
return false;
});
});
When I click on any button on any post it only activates the effect on the first post, the problem is that the buttons have the same name, so I'm looking for a way to specify each button. I tried jQuery ('. Faltpost'). Attr ("id"). Submit, but it did not work. the "$ id" is the number of the post, I'm taking a beating from JQUERY who help me and I'll give it a score.