I'm new in python, now I want use send variable from ajax to python with FLASK.
My html
$(document).ready(function(){
$('#submit_button').click(function(){
if (confirm("Are you sure you want to Process this form?")){
var form=$('#form2').serialize();
$.ajax({
url:"http://localhost:5000/",
method:"POST",
data:form,
success:function(){
$('#form2')[0].reset();
alert('Process Success');
}
});
}
});
});
Python
from flask import Flask
app = Flask(__name__)
'''def round_up(n, decimals=0):
multiplier = 10 ** decimals
return math.ceil(n * multiplier) / multiplier'''
@app.route('/', methods=['GET','POST'])
def main():
clicked=None
if request.method == "POST":
clicked=request.json['data']
return render_template('test.html')
if __name__ == "__main__":
main()
Can somebody help me with this?
Regards, Andri
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.