I have had this problem for couple of days now, My response from the Django is
di = { 0 : 'bat' , 1 : 'ball' }
js = json.dumps(js , indent=4)
print js
"""
{
"0": "bat",
"1": "ball"
}
"""
return HttpResponse(js)
now in my Ajax function:
$.ajax({
type: "POST",
url: "/some/url",
data: {
'name': "myname",
csrfmiddlewaretoken: '{{ csrf_token }}'
},
dataType: "json",
success: function (data) {
alert(data)
var to_parse = $.parseJSON(data);
alert(to_parse)
}
});
return false
}
I expect in alert(data)
the json value, but instead it get this: [object object]
Where am I going wrong?