Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有关使用节点js在html中单击按钮的信息_Javascript_Html_Node.js - Fatal编程技术网

Javascript 有关使用节点js在html中单击按钮的信息

Javascript 有关使用节点js在html中单击按钮的信息,javascript,html,node.js,Javascript,Html,Node.js,这是我的代码: file.html <html> <head> </head> <body> <form> <input type="button" value="hello1" onClick="window.location.reload()"/> <input type="button" value="hello2" onClick="window.location.reload()" /&

这是我的代码:

file.html

<html>
 <head>
 </head>
 <body>
  <form>
   <input type="button" value="hello1" onClick="window.location.reload()"/>
   <input type="button" value="hello2" onClick="window.location.reload()" />
  </form>
 </body>
我的问题是:在http.createServer(function(req,res){…})中是否可以区分单击了什么按钮?这个问题可能看起来很愚蠢,因为两个按钮都做相同的事情,但我需要能够做一件事。谢谢大家

var http=require('http');
var fs = require('fs');
var server = http.createServer(function(req, res){
    displayForm(res);
});

function displayForm(res) {
    fs.readFile('file.html', 'utf8', function (err, data) {
            res.writeHead(200, {'Content-Type': 'text/html'});
            res.write(data);
            res.end();
    });
 }

 server.listen(port, 'ip');
 console.log("Server running at http://ip:port/");