I am attempting to pass a Javascript Array from the client side to the server side (Flask). My code seems to work for both integers and strings. When I try to send an array with the exact same code, I get None
.
Server side code:
@app.route("/route1", methods=['GET', 'POST'])
def route1():
a = request.args.get('post')
result = json.dumps(a)
print(a)
print(result)
Client side:
$SCRIPT_ROOT = {{ request.script_root | tojson | safe }};
var x = ["test", "test2"];
function newFunction() {
console.log(x)
$.getJSON($SCRIPT_ROOT + '/route1', { post: x },
function (data) {
var response = data.result;
console.log(response);
}
)
};
As I said before, this seems to work perfectly when x
is simply assigned a string or an integer. When trying to pass through this array, I get None
and NULL
for my two print statements, respectively. How can I properly pass through the array to the server side?