这是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>
Run Code Online (Sandbox Code Playgroud)
这是在服务器上运行的node.js函数:
var sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
switch (req.url)
case '/myaction':
res.end(?????);
break;
} …Run Code Online (Sandbox Code Playgroud) 使用node.js作为客户端时,是否可以使用Windows集成身份验证连接到服务器(例如,连接到IIS时)?
我对此的搜索仅显示结果,其中node.js用作服务器.
我们可以使用require函数访问本地模块,但不能通过它访问全局模块.我在某处读到要使用全局模块,我们需要将其设置为本地,然后通过require函数导入它.因此,如果我们无法直接访问全局模块,那么使用它的需求是什么.
我想通过身份验证来使用这个rest api.我正在尝试包括标题但没有得到任何回复.它抛出的输出通常在没有认证时抛出.谁能建议我一些解决方案.下面是我的代码
var http = require('http');
var optionsget = {
host : 'localhost', // here only the domain name
port : 1234,
path:'/api/rest/xyz',
headers: {
'Authorization': 'Basic ' + new Buffer('abc'+ ':' + '1234').toString('base64')
} ,
method : 'GET' // do GET
};
console.info('Options prepared:');
console.info(optionsget);
console.info('Do the GET call');
var reqGet = http.request(optionsget, function(res) {
console.log("statusCode: ", res.statusCode);
res.on('data', function(d) {
console.info('GET result:\n');
process.stdout.write(d);
console.info('\n\nCall completed');
});
});
reqGet.end();
reqGet.on('error', function(e) {
console.error(e);
});
Run Code Online (Sandbox Code Playgroud) 这是代码
var t = ()=>{
setInterval(()=>{
console.log('hello')
},1000)
}
t();
clearInterval(t)
Run Code Online (Sandbox Code Playgroud)
为什么 clearinterval 不会阻止 setInterval 的执行?
我在windows azure中部署了nodeJS服务器.连接到服务器时我的客户端失败并处理以下错误:
WebSocket connection to 'wss://ooplrfrfranode.azurewebsites.net/socket.io/1/websocket/lHrd-DOydinODjbS7-tc' failed: Error during WebSocket handshake: Unexpected response code: 503.
Run Code Online (Sandbox Code Playgroud)
请帮忙.谢谢.