I have passed a JSON object to my twig template in symfony2, then i have assigned the object to JavaScript variable.
My object is like
[{"data":"{"params":{"id":"1","width":"98","height":"101","x":"151","y" ....
Now when i alert the object it shows the above objectarray() which is OK, but when i alert object.data it shows nothing.
Thanks
I don't know if you solved your problem.
I have the same trouble, but this worked for me
# your_template.html.twig
<script type="text/javascript">
{% autoescape false %}
var your_variable = {{ var_from_controller }};
{% endautoescape %}
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With