I have passed to template regular Python dictionary and I need to inside
$(document).ready(function() {.. }
to convert that Python dictionary to JavaScript dictionary. I tried like
var js_dict={{parameters}};
but I got errors ( ' instead of ‘ and all strings start with u’ ).
How can I convert Python dictionary to JavaScript hash table ?
Python and javascript both have different ideas about how to represent a dictionary, which means that you need a intermediate representation in order to pass data between them. The most common way to do this is JSON, which is a simple lightweight data-interchange format.
Use the python json library to convert (or dump) your python dict into a JSON string. Then in the javascript parse the JSON string into a javascript dict. (If you are using JQuery, then use jQuery.parseJSON)