简体   繁体   English

如何从 node.js 中的表单获取输入数据?

[英]How can i get input data from a form in node.js?

Working on a weather application in node.js But when i tried to get the input value through document.getElementById to show weather about a specific location it is showing error i have a file in my views folder where i provide JavaScript file using script tag but even then I am getting error.在 node.js 中处理天气应用程序但是当我尝试通过document.getElementById获取输入值以显示特定位置的天气时,它显示错误我的视图文件夹中有一个文件,我使用脚本标签提供 JavaScript 文件,但是即使那样我也会出错。

error is given below:错误如下:

GET http://localhost:3000/js/JavaScript.js net::ERR_ABORTED 404 (Not Found)

It is due to the fact that you are not serving a static files in your nodejs server.这是因为您没有在 nodejs 服务器中提供静态文件。 If you are using express server in your application you have to give the below code in main server js file app.use(express.static('public')) here public means the folder where you have html, js folder, css folder如果您在应用程序中使用 express 服务器,则必须在主服务器 js 文件app.use(express.static('public'))提供以下代码,此处 public 表示您拥有 html、js 文件夹、css 文件夹的文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM