1

I have the following javascript array at the client side -

["27", "28", "29", "30"] 

I am sending it to server as follows -

$.post(
  '/save/mempks/1/',
  {'data':elmArry},
  function(data){alert(data);});

On the server, I have put a debugger to see how, the data is received, and I see this unusual behaviour -

ipdb> request.POST
<QueryDict: {u'data[]': [u'27', u'28', u'29', u'30']}>

ipdb> request.POST.items()
[(u'data[]', u'30')]

ipdb> request.POST['data[]']
u'30'

All I want to do is extract, the numbers 27 to 30 and save it in a list.

Where are the numbers 27, 28, 29, and 30 are getting lost?

Could anyone suggest, why this behavior?

1

1 Answer 1

1

in case of posting list use request.POST.getlist('key') to get data. If you would use some kind of form for picking up posted data, then it would do it for you. https://docs.djangoproject.com/en/dev/ref/request-response/#id3

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.