Skip to content

Instantly share code, notes, and snippets.

@josegoyo
Created January 24, 2017 07:23
Show Gist options
  • Save josegoyo/60c2c9fdc9fb9a3fb6cc609ab58092ae to your computer and use it in GitHub Desktop.
Save josegoyo/60c2c9fdc9fb9a3fb6cc609ab58092ae to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<title> Acción onclick en js </title>
<!-- Aquí esta la referencia a jquery-->
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
$(document).on('ready',function(){
$('#btn-ingresar').click(function(){
var url = "datos_login.php";
$.ajax({
type: "POST",
url: url,
data: $("#formulario").serialize(),
success: function(data)
{
$('#resp').html(data);
}
});
});
});
</script>
</head>
<body>
<form method="post" id="formulario">
<input type="text" name="usuario" placeholder="Usuario" autofocus/>
<input type="password" name="contrasena" placeholder="Contraseña"/>
<input type="button" id="btn-ingresar" value="Ingresar" />
</form>
<!--Este div nos servirá para cachar la respuesta enviada
por el backend en caso de que sea necesario-->
<div id="resp"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment