O
O
ordinary_pavel2017-01-17 20:55:12
JavaScript
ordinary_pavel, 2017-01-17 20:55:12

How to pass data from server js to client js?

Good day to all. I recently started learning node.js and to consolidate my knowledge I am doing a small project. The essence is a simple directory of places on the map with directories. It is written in node.js, express, and 2gis maps (based on leaflet).
Question - how to transfer an array of data to maps? After all, they are spinning on the js client side, and the template engine (Hogan) passes data to html tags, but not to <script>. Please forgive my ignorance on some issues.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2017-01-17
@alexey-m-ukolov

A script is also a tag and you can render data into it in the form of a json string or in the form of js code tokens in the same way as you render them anywhere else.

I
Ivan, 2017-01-17
@LiguidCool

Either insert the template engine directly into the script tag , or request AJAX and separate the logic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question