我希望返回“价值”'属性来自以下链接:
<li><a href="/disable?server={{counter + loop.index0}}" id="count" value="{{ counter + loop.index0 }}">Click this to Disable </a></li>
JS:
<script type=text/javascript>
$(function() {
$('#count').bind('click', function(){
$.ajax({
method: "POST",
url: "{{ url_for('disableBtn') }}",
dataType: 'json',
data: { Count: $("#count").attr("value");}
})
.done(function(Data){
alert("Value = " + Data);
});
});
});
</script>
在我的app.py文件中,我有:
@app.route('/disable', methods=['GET', 'POST'])
def disableBtn():
valueOfButton = request.json['Count']
return jsonify(Data = valueOfButton)
如何返回&#39;值&#39;属性到链接所在的同一个模板,也可以用它作为数组索引的int?