Answer the question
In order to leave comments, you need to log in
What is the problem with indexing when passing a dictionary from django to jquery via json?
Good afternoon. I'm a little confused, please help.
In django, in view.py, I generate a multidimensional dictionary:
def get_actions_list(request):
actions_list_dict = {}
actions_list_dict['header'] = [
{'title': 'Дата', 'anchor': 'start_date'},
{'title': 'Оборудование', 'anchor': 'equipment'},
{'title': 'Тип', 'anchor': 'type'},
{'title': 'Вид', 'anchor': 'scheduled'},
{'title': 'Контейнер', 'anchor': 'old_container'},
{'title': 'Описание', 'anchor': 'description', 'tooltiped': True}
],
actions_list_dict['table_params'] = {
'html_id': 'actions_table',
'html_class': 'content_table'
},
return HttpResponse(
json.dumps({
"result": actions_list_dict,
}),
content_type="application/json"
)
$.ajax({
url: ajaxParams.url,
type: 'POST',
headers: {"X-CSRFToken": csrftoken},
data: ajaxParams.data,
success: function (json) {
var table = json.result
}, //end success
Answer the question
In order to leave comments, you need to log in
And what for commas in places ], and }, ? As written, this is how it works.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question