0
I have a comment list and I would like to send a specific email to a person on the list, but sending does not happen.
When I click on Answer back, the form box to fill the answer normally opens, however, by clicking on Send Email is not sent.
Follows the code:
while($painel_comentarios_artigos=mysqli_fetch_array($artigos_comentarios))
{
$idcomentario = $painel_comentarios_artigos['id'];
echo "<div class='titulo_comentarios'>".$painel_comentarios_artigos['nome']."</div><br>";
echo "<div class='msg_comentarios'>".$painel_comentarios_artigos['msg']."</div><br>";
echo "<div class='responder_comentarios'>
<a class='displayDiv' div-id='{$idcomentario}'>Responder</a>
</div><br>";
echo "<div id='div{$idcomentario}' style='display: none' class='txt_comentarios'>
<form div-id='{$idcomentario}' method='post'>
<textarea class='textarea_responder' name='cmt_resp'></textarea>
<input type='hidden' name='codigo' value=''>
<button class='btn_responder' type='submit'>Enviar</button>
<div id='msg_sugestao_resposta'></div>
</form>
</div><br>";
}
?>
</div>
<script>
$( "a.displayDiv" ).click(function() {
var id = $(this).attr('div-id');
$('div.txt_comentarios').css('display','none');
$('#div'+id).fadeIn(500);
// ENVIO DA RESPOSTA
$(function(){
$('#id').submit(function(event) {
event.preventDefault();
var formDados = new FormData($(this)[0]);
$.ajax({
url:'resenviar.php',
type:'POST',
data:formDados,
cache:false,
contentType:false,
processData:false,
success:function (data)
{document.getElementById('msg_sugestao_resposta').innerHTML = 'Sugestão enviada com sucesso.';
$('#id').each (function(){
this.reset();
});
},
dataType:'html'
});
return false;
});
});
// FIM DO ENVIO DA RESPOSTA
});
</script>
and the request reaches the method in "reserve.php"? where is the error? only "email is not sent" is too vague to help
– Ricardo Pontual
@Ricardopunctual as I do this debugging to inform you?
– Gladison
ai need to see which tool you use, can be done with "Xdebug" or "VS Code" for example. Before you even look at the
php
, open the browser developer tool and see the network tab, see if the ajax request was executed without errors, see if the data sent is correct (values, names, etc).– Ricardo Pontual
From what is presented, the button
Enviar
does absolutely nothing. The 1st step would be to paste the "Submit" you have in I know code like Onclick Ventbtn_responder
or correct the relationship of this Handler Event with the form.– tvdias