Ошибка типа: data.forEach не является функциейJquery

Программирование на jquery
Гость
Ошибка типа: data.forEach не является функцией

Сообщение Гость »


Это мой код:

Код: Выделить всё

$.ajax({
url: "some_url/",
type: "GET",
dataType: "json",
success: function(data){
console.log(data);
data.forEach(function(element){
console.log(element);
});
}
});
I get the error that for each does not work on the variable. However, when I log to the console, I get

Код: Выделить всё

[{"model": "app.mdl", "pk": 1, "fields": {"name": "test", "rank": 1}}]
This is clearly an array and iterable, so I don't get what exactly is wrong.

EDIT: is returned via

Код: Выделить всё

JsonResponse
in Django.


Источник: https://stackoverflow.com/questions/532 ... a-function

Вернуться в «Jquery»