Colleagues,
I have my index.html page with just two buttons and want to pass to Flask which one was pressed. I do see the GET message passing to the server the id, I am not beign able to get in flask/python
<!DOCTYPE html>
<html>
<script src="/static/jquery-1.11.3.min.js"></script>
<script src="/static/jquery.flot.js"></script>
<body>
<button type="button" id="ade" onclick="myFunction(this.id)">Adelante</button>
<button type="button" id="atr" onclick="myFunction(this.id)">Atras</button>
</body>
<script type="text/javascript">
function myFunction(clicked_id)
{
$SCRIPT_ROOT = {{request.script_root|tojson|safe}};
$.getJSON($SCRIPT_ROOT + '/',
clicked_id, function(data)
{
var response = data.result;
console.log(response);
}
);
}
</script>
</html>
on Flask I have
@app.route('/')
def indice():
clicked_id = request.args.get('clicked_id')
print clicked_id
Everytime i press the buttons I do get the id of the button, but in python I get None (on the print)
None
192.168.1.13 - - [07/Sep/2016 01:14:56] "GET /?atr HTTP/1.1" 200 -
None
192.168.1.13 - - [07/Sep/2016 01:15:02] "GET /?ade HTTP/1.1" 200 -
Any idea what might be wrong?