J
J
junqed2011-10-21 12:23:48
JavaScript
junqed, 2011-10-21 12:23:48

jQuery and Django: Sending an array in a POST request?

The thing is this: I send data using $.post

{<br>
    'string1': "23523".<br>
    'flags': (124, 126, 162).<br>
}<br>

flags is an array, Jquery processes it when sent, and as a result, the POST parameter changes the name to flags[].
In jung, for this reason, these brackets have to be taken into account (request.POST.getlist('flags[]')), but something is not very desirable. The question is, is there any solution? I did not find anything on the Internet on the topic

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yngvie, 2011-10-21
@Yngvie

If you use api.jquery.com/jQuery.ajax/ then you can pass the parameter
traditional: true
to it It just does what you want

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question