【问题标题】:sending data from template to flask将数据从模板发送到烧瓶
【发布时间】:2017-08-27 19:35:40
【问题描述】:

我正在使用烧瓶制作网站。 它使用 top.html 中的 sql 显示一个列表,其中每个元素都是一个超文本。

 <table class="table table-striped">
    <thead></thead>
  <tr>
    <th>Company</th>
  </tr></thead>
  <tbody>
        {% for company in companies %}
            <tr>
                <td><a href="{{ url_for('text') }}" method = "POST" name = "{{ company.name }}">{{ company.name }}</a></td>
            </tr>
        {% endfor %}
        </tbody>
</table>

所以我想知道从列表中单击了哪个超文本,以便我可以在 /text 中加载其各自的内容。 请同时提供python代码(烧瓶代码)。

【问题讨论】:

    标签: javascript python sql flask


    【解决方案1】:

    【讨论】:

    • 我应该在公司内部还是外部包括事件侦听器?
    • 另外请在python烧瓶中编写后端代码以访问那里的companyId。
    • ad 1. 将提供的 sn-p 放入 的循环之外的之后。广告 2. 我不知道您要公开哪些 REST 资源,但正如我在上面所写的,如果您点击了公司并且获得了公司 ID,您可以例如像这样进行 AJAX 调用:$.get("/details/" + companyId) ; //
    猜你喜欢
    • 2017-12-26
    • 1970-01-01
    • 1970-01-01
    • 2018-12-16
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 2020-09-26
    相关资源
    最近更新 更多