I'm trying to alert a log in success box after user has enter the name and pw using node server..This is the code for the button
<script>
$(document).ready(function(){
var user,pass;
$("#submit").click(function(){
user=$("#user").val();
pass=$("#password").val();
$.post("/login",{user: user,password: pass}, function(data){
if(data)
{
alert("login success");
}
});
});
});
</script>
This is the code for the post method..
app.post('/login',function(req,res){
var user_name=req.body.user;
var password=req.body.password;
console.log("User name = "+user_name+", password is "+password);
res.sendStatus(200);
res.end("yes");
});
Also, can i know where is a better place to learn these? like how does people kow res.sendStatus is there & how do use it ?
via newB
No comments:
Post a Comment