Issue
When I try to send an array to Django via Ajax (jQuery)
JavaScript code:
new_data = ['a','b','c','d','e'];
$.get('/pythonPage/', {'data': new_data},function(data){});
and I try to read the array:
Python:
request.GET.get("data[]")
I get only the last array value:
'e'
What am I doing wrong?
Solution
You're looking for the QueryDict
's getlist
request.GET.getlist('data')
request.GET.getlist('data[]')
request.GET.getlist('etc')
https://docs.djangoproject.com/en/2.0/ref/request-response/#django.http.QueryDict.getlist
Answered By - Yuji 'Tomita' Tomita Answer Checked By - Mildred Charles (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.