我用nodejs,express,做的后台,现在想要实现用户登录或者注册的无刷新验证,正好就是用$.ajax()或者$.post()了,但是没有成功,列出前台和后台代码,请大家指点下: 前台:$(“#txtUsername”).blur(function(){ $.post("…/login_verify", {"username":$(“#txtUsername”).val(), "password":$(“#txtPassword”).val()}, function(data){ alert(data); if (data == 1) { $(“#username.info”).html(“”); flag1 = true; return true; } else { $(“#username\.info”).css("color", “red”); $(“#username\.info”).html(“用户名错误!”); flag1 = false; return false; } }); }); 后台:User.get(req.body.username, function(err, user) { if(err){ console.log(err); } if (user) res.write(“0”); else res.write(“1”); res.end(); });
User.get(req.body.username, function(err, user) {
if (user.password != password) {
res.wirte("0");
}else {
res.write("1");
}
res.end();
});
错误时:db object already connecting, open cannot be called multiple times 求指导,大三学生