document.getElementByID() in Node.js using express

huangapple go评论65阅读模式
英文:

document.getElementByID() in Node.js using express

问题

我想知道是否可以使用express按ID获取元素。

如果不可能,我正在使用express将数据从我的网站传输到我的node.js服务器。是否可以从用户获取文本输入,然后将其应用于node.js变量?

如果不可能,我将采用WebSockets document.getElementByID() in Node.js using express

英文:

I would like to know if it's possible to get an Element by ID using express.

If it's not possible, I'm using express to transmit data from my website to my node.js server. Is it possbile to get a text input from the user, and then apply that in a node.js variable?

If that's not possible, I'll commit to websockets document.getElementByID() in Node.js using express

答案1

得分: 0

如果你需要实时更新,那么WebSocket是你唯一的选择(而不是每次用户输入时发送HTTP请求,这会使你的服务器负荷过重)。

然而,如果你不真正需要实时交互,你可以使用传统的表单POST(或其他)方法,并在最后使用来自表单的数据向你的Express后端发送HTTP请求。

希望这对你有帮助!

英文:

Well, if you want real-time update, then websocket is your only option (instead of sending HTTP request each time user inputs, which will flood your server).

However, if you don't really need real-time interaction, you can use old-way form POST (or any) method and send HTTP request to your express backend at the end with the data from the form.

Hope this helps!

huangapple
  • 本文由 发表于 2023年7月24日 17:08:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76752940.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定