Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
Send data as a response from nodejs server to html page so display it in table format

I'm new to programming, I'm trying to build a web app using nodejs/expressjs. so basically on the post route, after some processing on backend it gives an array of object in result variable, I want to use this result variable data and construct a table in html file and send this table.html file as a response to client

the problem I'm encountering is how can I use this result variable to add element of table in html file dynamically (since array size changes everytime )

approach i was using

  1. i created table.html and table.js that is linked with same html file.. but when table.html is send as a response that html file and table.js file is rendered on client side and not able to pass the result value that i get from server to that table.js file ( i get a document not defined error)
  2. i tried to use EJS template .. how to create a function that used ejs variable to loop through array data and show table.. i'm unable to do

if anyone can help me to show result=[{name:'james', id:23},{name:'joe',id:35}] to html file as response

main.js

app.post('/dataTbale',(req,res) => {
  // after some processing i get array of obj that i store in result variable
  const result=[{name:'james', id:23},{name:'joe',id:35}];
  res.send('table.html);
})

table.html

<html>
  <body>
    <h2>table</h2>
    <div id="show_table"></div>
    <script src="table.js"></script>
  </body>
</html>

table.js

const tableDiv=document.queryselector('#show_tabel');

result.forEach((obj) => {  //<==== i want to pass that result data here.
  tableDiv.innerHTML += result;
});

P.S just want to know if this works then i can create table

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You might use a template engine like (ejs) or any other template engines to show the dynamic data that returns back from the server and for the case that you want to render the results in different page you should store the data in any kind of storages like local storage or database to be able to use it in different places.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!