Reputation: 151
I am trying to give data from javascript to python, using post
On my Javascript
$('ABC').on("click", function(){
$.post( '/user',
{
user: 'here'
}
)});
And giving this to python
@app.route("/user", methods=['GET', 'POST'])
def user():
id = user
return id
Above code should show html with just user.
But page does not move when on click..
Any idea?
Upvotes: 1
Views: 93
Reputation: 782407
You need to provide a callback function in $.post
$('ABC').on("click", function() {
$.post('/user', {
user: 'here'
}, function(response) {
$("#result").html(response);
});
});
You can also abbreviate this to the .load()
method:
$('ABC').on("click", function() {
$("#result").load('/user', {
user: 'here'
});
});
Upvotes: 1