Friends, i'm trying to get ajax json response in django.
While the console log shows every json object, the same is not true while parsing the json and adding a field to a division in html. Only one object's field shows up.
my javascript is as follows
$("#all_questions").on("click",
function(event){
all_questions();
}
);
function all_questions()
{
console.log("all_questions() working..");
$.ajax({
url : "/questions",
type : "GET", // http method
data : { },
success : function(json) {
console.log(json); // log the returned json to the console
$("#content").empty();
data = JSON.parse(json);
$.each(data, function(idx, obj) {
$('#content').html(obj.fields.title);
});
}
,
error : function(xhr,errmsg,err) {
console.log(xhr.status + ": " + xhr.responseText);
}
});
}
I can't figure out where i'm going wrong.