I use nodejs + express, as a template engine - ejs. Question: can I somehow transfer data from this client js to this template engine? That is, something like this should come out: var someVar = someData and then in the html file <%= someVar %> .

  • So ejs works without problems on the server and on the client. Not quite clear what the problem happened. - Nasty Pacman
  • Well, for example, in order to transfer data from a node to ejs, I use res.render('index', {someVar: 'someVal'}) . And how can I transfer a variable from client js? Is it possible? - Veneomin
  • So it’s almost the same on the client: new EJS url: 'index.ejs' .render someVar: 'someVal' - Nasty Pacman
  • Yes, this is a working option for when ejs is connected directly to the file. And how to do this when it is connected via a nodejs + express? I get in the browser that: Uncaught ReferenceError: EJS is not defined - Veneomin
  • one
    Sam ejs also need to connect to the browser. - Nasty Pacman

1 answer 1

Jquery:

 $('html tag').html(someVar); 

js:

 document.body.getElementById('htmltag').innerText = somveVar; 

Why complicate