Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Usando Ajax</title>
- </head>
- <body>
- <form id="formulario_contato">
- <input type="text" name="nome" id="nome" required />
- <input type="email" name="email" id="email" required />
- <textarea name="message" id="message"></textarea>
- <input type="submit" name="enviar" value="Enviar" />
- </form>
- <script src="jquery.min.js"></script>
- <script>
- $(function(){
- $("#formulario_contato").on('submit', function(event){
- event.preventDefault();
- // Pegando os dados
- var nome = $("#nome").val();
- var email = $("#email").val();
- var message = $("#message").val();
- // enviando o request
- $.ajax({
- url: 'http://meusite.com.br/phpmailer.php',
- type: 'POST',
- dataType: 'json',
- data: {nome:nome, email:email, message:message},
- success: function(data){
- console.log(data);
- }
- });
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment