This is my code:
$.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 data variable. However, when I log data 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: data is returned via JsonResponse in Django.