Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

259
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda