这是在HTML形式例如:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>CSS3 Contact Form</title>
</head>
<body>
<div id="contact">
<h1>Send an email</h1>
<form action="/myaction" method="post">
<fieldset>
<label for="name">Name:</label>
<input type="text" id="name" name="name" placeholder="Enter your full name" />
<label for="email">Email:</label>
<input type="email" id="email" placeholder="Enter your email address" />
<label for="message">Message:</label>
<textarea id="message" placeholder="What's on your mind?"></textarea>
<input type="submit" value="Send message" />
</fieldset>
</form>
</div>
</body>
</html>
这是在服务器上运行的node.js功能:
var sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
switch (req.url)
case '/myaction':
res.end(?????);
break;
}
}).listen(8080);
sys.puts('Server running at http://127.0.0.1:8080/');
我有2个问题:
- 我怎么能叫
myaction
从HTML页面Node.js的功能? 因为HTML文件运行在端口80和Node.js的8080(当我尝试移动到80端口写入“//未处理的‘错误’事件” Node.js的) - 在Node.js的功能,我把“?????” 我怎样才能从HTML表单数据。 当我输入req.html.body.name我没有得到的数据...