python - Flask: using JSON to return value of attribute -
i'd return 'value' attribute following link:
<li><a href="/disable?server={{counter + loop.index0}}" id="count" value="{{ counter + loop.index0 }}">click 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>
in app.py file have:
@app.route('/disable', methods=['get', 'post']) def disablebtn(): valueofbutton = request.json['count'] return jsonify(data = valueofbutton)
how can return 'value' attribute same template link in , able use int index of array?
Comments
Post a Comment