【发布时间】:2017-07-29 22:31:21
【问题描述】:
我目前正在使用 Flask 和 python。我的 html 文件有以下代码:
<body>
{% for result in rest_info %}
<div class="cotainer">
<button class="btn btn-primary" type="submit" id="{{result2}}">{{result[2]}}</button>
</div>
{% endfor %}
</body>
我想根据单击的按钮转换到不同的 html。我编写了类似这样的 jQuery 脚本来获取按下按钮的值:
$(document).ready(function() {
$(this).click(function() {
var stored_value = $(this).id;
});
});
我想知道如何将 stored_value 传递给 Flask python 中的视图函数...感谢您的帮助! 编辑:按钮列表任意长!
【问题讨论】: