我有一个简单的用户注册表格,如下所示:
<form class="form-inline" action="/" method="post">
<div class="form-group">
<label class="sr-only">Username</label>
<input name="username" type="text" class="form-control" placeholder="Desired Username">
</div>
<br>
<br>
<div class="form-group">
<label class="sr-only" for="exampleInputEmail3">Email address</label>
<input name="email" type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
</div>
<br>
<br>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword3">Password</label>
<input name="password" type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
</div>
<br>
<br>
<button type="submit" class="btn btn-default">Register</button>
</form>
这是我的app.js服务器端代码。
app.post('/', function(req, res) {
var user = new Parse.User();
user.set("username", req.body.username);
user.set("password", req.body.password);
user.set("email", req.body.email);
user.signUp(null, {
success: function(user) {
// Hooray! Let them use the app now.
console.log(user);
res.render('landing', { message: 'Registered' });
},
error: function(user, error) {
// Show the error message somewhere and let the user try again.
console.log(error.message);
res.redirect('/#register');
}
});
});
我知道alert();
在node.js的服务器端不存在。
我想知道我可以为用户提供某种类型的警报以及让他们知道app.post的状态。