我正在使用node.js和jQuery Mobile,我在处理表单时遇到了一些问题。 我怎么能渲染下一页?我应该将什么传递给渲染函数?
感谢您的帮助!
HTML CODE:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page" id="page1">
<h1>Welcome To My Homepage</h1>
<form method="POST" action="/main" name="login">User name
<input required="required" name="username" type="text" value=""> <br>
<br>
Password <input required="required" name="password" type="password" value=""><br>
<br>
<input value="Login" name="Login" type="submit"></form>
</div>
<div data-role="page" id="page2">
<h1>SUCCESS</h1>
</div>
<div data-role="page" id="page3">
<h1>FAIL</h1>
</div>
</body>
</html>
Node.js的:
app.post("/main", function (req, res) {
.
.
.
if (user != null) {
console.log("User Found");
res.render(??????); --> render #page2
} else {
console.log("Username and password don't match");
res.render(??????); --> render #page3
}
}