0

Unable to access cols_data javascript array in flask request.form.

I have tried following

  • request.form.getlist('cols_data')- didn't work
  • request.form.getlist('cols_data[]')- Also didn't work

Find request form data below:

_csrf_token:1497597543.06##084136a9d79f2879bd33eaadf1095f41e9323192
cols_data[0][col][a]:2
cols_data[0][col][b]:BELL
cols_data[0][col][c]:0
cols_data[0][col][d]:All
cols_data[0][col][w]:abc,drf,cbf,dfdf
cols_data[0][col][cust_display_name]:2
cols_data[1][col][a]:2
cols_data[1][col][b]:BELL
cols_data[1][col][c]:0
cols_data[1][col][d]:All
cols_data[1][col][w]:as,ds,fd,ef
cols_data[1][col][cust_display_name]:3
cols_data[2][col][a]:2
cols_data[2][col][b]:BELL
cols_data[2][col][c]:0
cols_data[2][col][d]:All
cols_data[2][col][w]:nhh,scni,cjik
cols_data[2][col][cust_display_name]:4
cols_data[3][col][a]:1
cols_data[3][col][b]:MNN
Himanshu dua
  • 2,496
  • 1
  • 20
  • 27

1 Answers1

-1

As it has already been said if the data is sent through jquery you need to use:

cols_data = request.get_json()  
# Do what you need with cols_data

If that does not help try to print request.args, request.form and request.data to see what is in there:

print('REQUEST.FORM: ', request.form)
print('REQUEST.ARGS: ', request.args)
print('REQUEST.DATA: ', request.data)
Nurjan
  • 5,889
  • 5
  • 34
  • 54