Sunday, 15 September 2013

jQuery json value is not being appended

jQuery json value is not being appended

This is my code:
success: function (data) {
var jsonData = $.parseJSON(data);
console.log("done");
$.each(jsonData, function(key, value) {
if (value !== "") { console.log("working on " +
"#"+key+".div")
$("#"+key+".div").append("<pre>"+value+"</pre>");
}
});
}
As you see, this is a snippet of the success callback function.
Everything works fine up to the point where value should be appended to
the selector I provide. But for some reason, nothing is added.
console.log("working on " + "#"+key+".div")
Is printed, so I know the if statement is not the issue.
I believe the error lays with this line:
$("#"+key+".div").append("<pre>"+value+"</pre>");
But I can't tell what exactly I am missing.

No comments:

Post a Comment