Consider, I am sending JSON to client as follows in render page of Express (using hbs as a view engine):
res.render('MyPage.html', { layout: false, PageTitle: 'Project Name', JSON_Data: {field1:'value',field2:'value2'}});
I am able to access and set title of html page by using {{PageTitle}}
, following is the code.
<title>{{PageTitle}}</title>
Now I want to show JSON_data
into alert popup.
I've tried following way, but getting Uncaught SyntaxError: Unexpected token {
, while debugging in chrome is shows var jsonobj = [object Object]
function fbOnBodyLoad() {
var jsonobj = {{JSON_data}};
alert(jsonobj);
}
Could any body give some idea on How to access JSON_data
and show in alert
Advance Thanks