Cómo obtener una matriz en Django publicado a través de Ajax
Cuando intento enviar una matriz a Django a través de Ajax (jQuery)
Código JavaScript:
new_data = ['a','b','c','d','e'];
$.get('/pythonPage/', {'data': new_data},function(data){});
Y trato de leer el array:
Python:
request.GET.get("data[]")
Solo obtengo el último valor del array:
'e'
¿Qué estoy haciendo mal?
28
1 answers
Estás buscando los 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
57
Author: Yuji 'Tomita' Tomita,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-24 07:09:08
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-24 07:09:08