简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM