如何将.EJS文件中声明的对象导出到我的index.js
我的.ejs文件中有一个脚本,脚本很简单,我只是从用户那里抓住输入数据并将其放入对象中。因此,我要做的是将此对象发送到我的index.js,在我的index.js中,我将使用来自对象的数据在名为COAP的节点模块中使用(对HTTP非常模拟),但是我真的不知道如何将我的对象表单一个.ejs文件发送到我使用的Express模块的index.js文件。
const btnSubmitData = document.getElementById("btnSubmitData")
btnSubmitData.addEventListener("click", () => {
const boardIP = document.getElementById("BoardInputIP").value
const boardMethod = document.querySelector('input[name="inlineRadioOptions"]:checked').value
const boardFunction = document.getElementById("selectFunction").value
const boardPoint = document.getElementById("selectPoint").value
const inputDataBoard = {
ipBoard: boardIP,
methodCoapBoard: boardMethod,
functionBoard: boardFunction,
pointBoard: boardPoint
}
})
I have a script inside of my .ejs file, the script is very simple, I'm just grabbing the input data from the user and putting inside an object. So, what I want to do is to send this object to my index.js and in my index.js I'm gonna use the data from my object to use in a node module called coap (is very simular to http), but I don't really know how to send my object form a .ejs file to my index.js file which I'm using the express module.
const btnSubmitData = document.getElementById("btnSubmitData")
btnSubmitData.addEventListener("click", () => {
const boardIP = document.getElementById("BoardInputIP").value
const boardMethod = document.querySelector('input[name="inlineRadioOptions"]:checked').value
const boardFunction = document.getElementById("selectFunction").value
const boardPoint = document.getElementById("selectPoint").value
const inputDataBoard = {
ipBoard: boardIP,
methodCoapBoard: boardMethod,
functionBoard: boardFunction,
pointBoard: boardPoint
}
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要使用EJS显示 - 而不是index.js吗?
don't you have to use ejs to display - not index.js?