0
I’m trying to send a post without refresh with this method below but only sends the first form the second it redirects to page, I’m with the Forms inside a while PHP
$(function($) {
$('#enviaadv').submit(function() {
$(this).ajaxSubmit(function(resposta) {
if (!resposta){
$onclick = showadv('bottom','left',resposta);
}
else
{
$onclick = showadv('bottom','left',resposta);
}
});
return false;
});
});
</script>
<form id="enviaadv" action="functions/advogadoresponsavel.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="advid" value='awdawd'>
<input type="hidden" name="advnome" value='awdawd'>
<input type="hidden" name="idunico" value='adawdaw'>
<button class="btn btn-success btn-link btn-just-icon btn-sm">
<i class="material-icons">person_add</i>
</button>
</form>
<form id="enviaadv" action="functions/advogadoresponsavel.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="advid" value='dawd'>
<input type="hidden" name="advnome" value='awdawd'>
<input type="hidden" name="idunico" value='awdawd'>
<button class="btn btn-success btn-link btn-just-icon btn-sm">
<i class="material-icons">person_add</i>
</button>
</form>
Ids must be unique!
– Gabriel Heming
i need to put the script inside the while?
– Joao Pedro P M
While? It makes even less sense, because there is no while in your code. If you want to "repeat an id", use
class
instead. Anyway, it’s strange to have two presses.– Gabriel Heming
has worked http://prntscr.com/jwfd6l but has no better method of doing so?
– Joao Pedro P M
Leave the script out of the loop and change the selector to
$('form').submit(function(){
... the form that is sent will be automatically captured.– Sam
But I don’t want you to take all the Forms from the page just the uqe are in the loop
– Joao Pedro P M