Skip to content
Advertisement

trying to send some data from nodejs to script in html

I am using hbs as view in frontend. I tried to send data to my script in html from nodejs like this :

JavaScript

});

then when i am trying to call it here in script using javaScript it tells me something is wrong

JavaScript

I want to know how correctly call the the object in script

edit:

the data should be something like this :

JavaScript

Advertisement

Answer

For EJS example if pass data msgs:

JavaScript
  1. js handle data:
JavaScript
  1. print directly:
JavaScript
  1. save in global variable
JavaScript

And for handlebars:

JavaScript
JavaScript

u could check out this similar issue:) How to define an array within a <script> tag inside a hbs view template

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement