[英]How to send data as a response from nodejs server to html page so display it in table format
I'm new to programming and I'm building a project which is a web app using nodejs/express js server.我是编程新手,正在构建一个项目,该项目是使用 nodejs/express js 服务器的 Web 应用程序。 I'm stuck at making a table with my response that I get back from server.
我被困在用我从服务器返回的响应制作表格。
app.get('/')
I go to homepage and do some task and click submit button that post the data to serverapp.get('/')
我转到主页并执行一些任务,然后单击将数据发布到服务器的提交按钮result=[{},{},{}]
result=[{},{},{}]
的对象数组res.json({staus:200,values:result})
fromres.json({staus:200,values:result})
时,我可以看到这个结果app.post('/result',< handler fuction >()=>{ // perform some task and get result into result variable res.json({staus:200,values:result}) })
I tried to create a basic html file and return this file in res.send('table.html')
that was loading a in an external javascript file and this file tries to append table.html to create table.我试图创建一个基本的 html 文件并在
res.send('table.html')
中返回这个文件,该文件正在加载一个外部 javascript 文件,这个文件试图附加 table.html 来创建表。 But I don't know how I can send result
var from server to this file that works on client side.但我不知道如何将
result
变量从服务器发送到这个在客户端工作的文件。
您可以使用像 (ejs) 或任何其他模板引擎这样的模板引擎来显示从服务器返回的动态数据,如果您想在不同的页面中呈现结果,您应该将数据存储在任何类型的存储中像本地存储或数据库一样能够在不同的地方使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.