Oie
I did following:
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();
}
});
});
});
PHP file receivedData.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);
It deletes the div minhaDiv
, but did not show the other