V
V
Vitaly2015-10-13 17:37:59
JavaScript
Vitaly, 2015-10-13 17:37:59

How can I pass the data of the express project variable to the client-side JavaScript, from the public folder, included in index.ejs?

The only thing that comes to mind is to send an ajax request to the document, and in the response to receive the data of that variable.
Perhaps there is an option, as in the case of ejs, when data is transmitted along with the page, data is transmitted through <%= value =%>
?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Костя Нечаев, 2015-10-23
@kos403

Можете записать эту переменную в DOM дерево и потом достать её с помощью JS из html вёрстки
к примеру
div data-var=<%= myVariable %>
после парсинга шаблонизатором на стороне сервера вместо myVariable подставиться переменная

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question