Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
How to use Django variable in JavaScript /jQuery?

I am passing a list of name subject in my HTML template from views.py but it's not working the way its working when I pass a list statically.

Also, It's by default converting into Unicode (that I don't want)

Following is my code,

var data = "{{subject}}";
    console.log("data before for loop",data)    
    var i;
         
        for (i = 0; i<data.length; i++)
        {
            data = data.replace("&#39;", "'");
        }

    console.log("data after for loop",data)
    var t2 = ['IT', 'Maths', 'History', 'Civics', 'Virtualization', 'BIO', 'EH', 'Chemistry'];
    console.log(typeof data);
    console.log(typeof t2)

and following is the output of console.log,

data before for loop [&#39;IT&#39;, &#39;Maths&#39;, &#39;History&#39;, &#39;Civics&#39;, &#39;VWE&#39;, &#39;BIO&#39;, &#39;EH&#39;, &#39;EHas&#39;]

data after for loop ['IT', 'Maths', 'History', 'Civics', 'VWE', 'BIO', 'EH', 'EHas']

string

object

I want to know why it's not working.. and how can I make it work..

Thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!