Created
November 7, 2014 05:32
-
-
Save giobyte8/8f3e4adc61d79736f207 to your computer and use it in GitHub Desktop.
Parte 2 | Creando un sistema de chat sobre NodeJS con Socket.IO, ExpressJS, MongoDB, Foundation y Openshift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Signup to chat team SS</title> | |
</head> | |
<body> | |
<h1> Signup to chat team SS</h1> | |
<form id="signup-form"> | |
<label for="username">Username</label><br> | |
<input id="username" name="username" placeholder="Choose an username" required> | |
<br><br><label for="password">Password</label><br> | |
<input id="password" name="password" placeholder="Type a password" type="password" required> | |
<br><br><label for="email">Email</label><br> | |
<input id="email" name="email" placeholder="User email" type="email" required> | |
<br><br><button onclick="signup()" type="button">Signup</button> | |
</form> | |
<br><span id="msg"></span> | |
<script src="http://code.jquery.com/jquery-1.11.1.js"></script> | |
<script type="text/javascript"> | |
/** | |
* Esta funcion se ejecuta al hacer clic en el boton 'Signup' | |
* registra mediante ajax al nuevo usuario | |
*/ | |
function signup() { | |
$.ajax({ | |
type: "POST", | |
url: '/signup', | |
data: $('#signup-form').serialize(), | |
success: function (data) { | |
$('#msg').empty(); | |
if (data.error) { | |
$('#msg').append(data.err.msg); | |
} | |
else { | |
$('#msg').append('User registered successfully'); | |
$('#signup-form')[0].reset(); | |
window.location = '/'; | |
} | |
}, | |
dataType: 'json' | |
}); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment