【发布时间】:2021-12-30 02:29:06
【问题描述】:
我正在尝试从下拉菜单中检索所选选项。但它似乎没有给我任何回报。我尝试使用 ajax 发布选定的值,但效果不佳。请赐教。
$.ajax({
url:"/dashboard",
type:"POST",
data: {
Sel =data['Sel']
},
error: function() {
alert("Error");
},
success: function(data, status, xhr) {}})
在烧瓶中 request.method="POST":
@app.route('/dashboard',methods=['GET','POST'])
@login_required
def dashboard():
select= request.form.get('val')
# select= request.form.get('Sel')
print(select)
在html中:
<form action="/dashboard" method="POST" name="dashboardform" id="dashboardform">
<div class="dropdown-menu">
<p>Select Period </p>
<select id="Sel">
<option value="All"> All </option>
{% for result1 in result[:] %}
<option value="{{result1}}">{{result1}}</option>
{% endfor %}
</select>
</div>
</form>
【问题讨论】: