amankarn amankarn - 1 year ago 109
jQuery Question

Parsing json returns only one object in django jquery

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


function all_questions()
console.log("all_questions() working..");

url : "/questions",
type : "GET", // http method
data : { },

success : function(json) {
console.log(json); // log the returned json to the console
data = JSON.parse(json);
$.each(data, function(idx, obj) {

error : function(xhr,errmsg,err) {

console.log(xhr.status + ": " + xhr.responseText);

I can't figure out where i'm going wrong.

Answer Source

The problem lies in this line:


Every time you refresh html, you only pass one value to it. Try appending the content in an html file, or creating multiple instances (as a list ro something)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download