So I have this simple python script running on Flask that I'd like to pass variables to with an ajax jQuery request. I might be missing something obvious but I can't get it to work properly.
@app.route('/test', methods=['GET', 'POST'])
def test():
my_int1 = request.args.get('a')
my_int2 = request.args.get('b')
my_list = [my_int1, my_int2]
with open('my_csv.csv', 'wb') as myfile:
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
wr.writerow(my_list)
return '' #does one have to have an return even tho it is just a script?
So, above will work fine when just passing parameters to the URL field: http://127.0.0.1:5000/test?a=10&b=25 however, trying this in the chrome console will not yield any output at all:
$.ajax({
method: "POST",
url: "127.0.0.1:5000/test",
data: {a: 10, b: 25},
dataType: "script"
});
What am I missing and why does the above jquery ajax request not work? $.ajax is not a function(…)