I am returning from my django code JSON and it looks like this:
my django code:
objs = AccessInfo.objects.filter(~Q(weblink=''))
return HttpResponse(serializers.serialize('json', objs), mimetype="application/json")
what I get in frontend is:
I want to be able to iterate over those JSON objects in frontend with javascript and show each fields
value in some html.
If I alert(data)
, I am getting [ Object, Object ]
.
I tried $.parseJSON(data)
, but i am getting:
SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
how can I do it?
UPDATE:
my js is receiving the data like this:
$.ajax({
url: '/get_book_access_downloads/',
type: 'get',
data: {bookid:bookid},
dataType: 'json'
}).done(function(data){
// to do
});