Tuesday, February 25, 2020

Re: django context data into javascript

But I'm getting one error

On Tue 25 Feb, 2020, 5:59 PM Naveen Arora, <naveenarorakrnl@gmail.com> wrote:
Hi, this is simple just enclose {{name}} into " " as "{{name}}" for your part.

Thanks

On Tuesday, 25 February 2020 15:56:05 UTC+5:30, Soumen Khatua wrote:
Hi Folks,

I'm sending some context data into html like 
name = 'soumen'
return render(request,'xyz.html', context = {'name':name})

inside myjs.js(js script has been integrated to html):
-------------------------------------------------------------------
var my_name = {{name}};

I'm getting an error::: Uncaught SyntaxError: Unexpected token '{'

So,How I can render data into frontend??

Thank You in advance

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b6c9cd98-b9bd-4178-919a-13d8156029a6%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WatGXxg0G%3DxC%3DS8ddMFmMpQm-TeZ8B2zZxZi9AAFj8npA%40mail.gmail.com.

No comments:

Post a Comment