Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

257
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda