【发布时间】:2019-07-28 09:12:23
【问题描述】:
我有一个 html 页面,我想通过单击按钮打开对话框,并且应该动态生成对话框的内容。
思路如下:
- 我点击按钮
- JS(ajax)运行我的flask route,执行对其他站点的http请求,然后返回json
- 返回的json传递给js(或html),然后解析这个json,根据找到的信息,在打开的对话框中显示元素(以图片为例)
Python:
@app.route('/sales_inventory', methods=['POST'])
def tm_inventory(user):
response = some_function("authKey")
return make_response(jsonify(response)))
HTML:
<button class="inventory">Inventory</button>
<div class="modal">
<div class="modal-content">
<span class="close">×</span>
</div>
</div>
元素应该在 div .modal-content 中生成
JS:
$(."inventory").click(function () {
$.ajax({data: {
user: $(this).next().text()
},
type: 'POST',
url: '/sales_inventory'
})
js没有完成,因为不知道应该怎么写
【问题讨论】:
标签: javascript html ajax python-3.x flask