【问题标题】:How to store javascript variable into python(django)如何将javascript变量存储到python(django)中
【发布时间】:2014-05-10 11:28:18
【问题描述】:

流程

JavaScript 提示(提示值)-> python (django)-> 使用 django 我想将该值存储在 xml 文件中

【问题讨论】:

  • 你试过用ajax的post方法吗?

标签: django django-models django-forms


【解决方案1】:

在这里,您可以使用提示值向 django 发送 GET/POST ajax 请求。

<script>    
            window.onload = function() {     
            var name = prompt('What is your name?', '');    
            // send your ajax request     
             $.ajax({    
             type:"GET",    
             url:"/store_prompt/"+name,    
             success: function(data){    
                 alert('prompt value is stored into xml file.');    

             }    
        });    

    }
</script>

在 django 中,您可以轻松编写逻辑以将值存储到 xml 文件中。

【讨论】:

    猜你喜欢
    • 2020-09-10
    • 1970-01-01
    • 2013-08-06
    • 1970-01-01
    • 2018-04-15
    • 2020-05-10
    • 2018-09-05
    • 2022-11-23
    • 1970-01-01
    相关资源
    最近更新 更多