N
N
Neoliz2015-12-03 08:55:02
JavaScript
Neoliz, 2015-12-03 08:55:02

Why is an array being passed from js to python as a string??

Hello! Me again. Help me please. Why when a view accepts it sees it as a string?? And when there are several objects, then several lines.
In general, the question is this. How can I form an array of numbers or words in js and pass it through ajax to the view, and then process this array. Those. go through each element. ???
Please don't throw tomatoes, I'm just learning.
Show how to wrap an array in js, and how to parse it in python.
Googled, didn't help.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2015-12-03
@timofeydeys

You can only transfer strings via HTTP.
Use JSON.

A
angru, 2015-12-03
@angru

import json


json_data = json.loads(request.body)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question