How can I make a submission with ajax using the enter key? That is, I have the following code:
var nome = $("#nome").val();
jQuery.ajax({
method: "get",
url: "teste.php",
data: { "nome": nome },
success: function(data){
alert("Enviado com Sucesso!");
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>Nome:<inputtype="text" name="nome" id="nome" placeholder="Digite seu Nome">
<button>Enviar</button>
How can I do this, so that when I press the enter key, I will be submitted to the input?