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?
1 Answer 1
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'
});
});
answered Dec 6, 2018 at 1:06
Barmar
789k57 gold badges555 silver badges669 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default
console?<form>.