0
Oie
I did next:
HTML
<div id="minhaDiv">
<form id="formulario">
<input type="text" name="nome" id="nome" autocomplete="off" placeholder="Digite seu Nome">
<input type="text" name="email" id="email" autocomplete="off" placeholder="Digite seu email">
<input type="button" id="salvar" name="salvar" value="Salvar" class="btn-toggle" data-element="#minhaDiv">
</form>
</div>
<div id='msgsucess' class='output' style="display: none">
Obrigado por entrar em contato.
</div>
JS Query
$(document).ready(function (){
$("#salvar").click(function (){
var form = new FormData($("#formulario")[0]);
$.ajax({
url: 'recebeDados.php',
type: 'post',
dataType: 'json',
cache: false,
processData: false,
contentType: false,
data: form,
timeout: 8000,
success: function(e){
e.preventDefault();
el = $(this).data('element');
$(el).toggle();
$('#minhadiv').hide();
$('#mgssucess').show();
}
});
});
});
File in PHP receipts.php
$nome = $_POST['nome'];
$email = $_POST['email'];
$headers = "MIME-Version: 1.1\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
$headers .= "From: [email protected]\r\n"; // remetente
$headers .= "Return-Path: [email protected]\r\n"; // return-path
$envio = mail("[email protected]", "$nome", "$email", $headers);
He erases the div minhaDiv
, but did not show the other
Wow, but I changed and still no div with the message
– Junior
what’s in the output class in your CSS? tried to inspect the
html
and see if thediv
is really hidden?– Ricardo Pontual
has no css, yes this appearing hidden
– Junior
I made an example here (apart from the Ajax call) that is working perfectly: https://jsfiddle.net/8b1fw88y/1/
– Ricardo Pontual
note that in your example this line
$('#minhadiv').hide();
is wrong too, since theJavascript
is case sensitive, should be like this:$('#minhaDiv').hide();
– Ricardo Pontual