ketan khandagale
ketan khandagale

Reputation: 461

How to pass data from javascript to django?

I'm pretty new to Django (and web development) and find myself struggling with this problem. I'm able to pass the data from Django to javascript HTML

 function load_led(){
    {% for leds in led %}

        var str2 = "{{leds.name}}"
        var x = {{leds.x}}
        var y = {{leds.y}}
        var w = 30
        var h = 30
        var fill = "{{leds.color}}"

        document.getElementById("FirstName").value = str2;
        document.getElementById("xposition").value = x;
        document.getElementById("yposition").value = y;
        document.getElementById("status").value = fill;

        add1(x,y,fill);
    {% endfor %} 
} 

Now I change the values of Elements and then want to pass this values again to Django so that I can update my database. So how can I pass the values from javascript or from HTML page

Upvotes: 4

Views: 8283

Answers (1)

jbartolome
jbartolome

Reputation: 302

You need to make an ajax call or similar to pass data to the server. You can make it very fast with jquery

Upvotes: 1

Related Questions