Hello!

I have a view from which I need to transfer a JSON object.

did this:

return render_to_response("catalog/item.htm", {'json_obj': json.dumps(images)}) 

but if i just try to insert

 {{json_obj}} 

in javascript code then this doesn't work.
Apparently Dzhangovskiy template maker does not allow to embed variables in scripts, because just in html, this line is displayed correctly.
Tell me how to transfer a JSON object to JavaScript?

    1 answer 1

    Working example

     return HttpResponse(simplejson.dumps({"success": True}), content_type="application/json") 
    • Yes, I did it. I can’t figure out how to make the return the template I need, while the JSON string is passed to JavaScript. - iterq
    • 2
      var a = "{{json_obj | escapejs}}"; - LinnTroll