I wanted to know how to send a form without refresh, I was able to put it to not refresh but I want a screen to appear shortly after giving the submit type "Email sent successfully".
I wanted to know how to send a form without refresh, I was able to put it to not refresh but I want a screen to appear shortly after giving the submit type "Email sent successfully".
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sem título</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script></head><scripttype="text/javascript">
$(document).ready(function () {
$('#forms').on('submit', function() {
$.ajax({
url: 'dados.php',
type: 'post',
data: $('#forms').serialize(),
success: function(data) {
$(".menu").show('fast');
$('#atuar').show('fast'); }
});
return false;
});
});
</script>
<style>
.menu{
position: relative;
float: left;
width: 300px;
background: #12C12B;
}
#atuar{
position: relative;
float: left;
clear: left;
margin-top: 5px;
background: red;
}
</style>
<body>
<div>
<form id="forms">
<input type="text" name="name" placeholder="digite o nome" />
<input type="submit" value="enviar" />
</form>
</div>
<div class="menu" hidden>enviado com sucesso!</div>
<div id="atuar" hidden ><input type="button" value="download"></div>
</body>
</html>
Now the page that receives the data data.php
<?php
$dados = $_POST['name'];
?>
Try to do this using jquery and ajax:
<p></p>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script></script><script>$(document).ready(function(){varjson='{"mensagem":[{' +
'"assunto":"' + tIdP + '",' +
'}]}';
$.ajax({
type: 'POST',
url: 'file.php',
data: {'json': json},
success: function (data) {
$('p').append('Mensagem enviada com sucesso!");
}
});
});
</script>