我在 python 中创建了一个列表,然后将其转换为 json。但我无法在 javascript 中迭代并显示正确的项目。
有什么建议吗?
Python:
def friends2(request):
fb_feed = [#data in here]
b = json.dumps(fb_feed)
print b
return HttpResponse(b)
当我print b
:
[
[1236870349, "Your friend", "Bhangra indian Jingle Bells balle balle Merry Christmas", "2lPdXV1KO4s", "Your friend watched \"Bhangra indian Jingle Bells balle balle Merry Christmas\""],
[2303218, "Your friend", "Look at this Instagram (Nickelback Parody)", "ttp://www.c", "Your friend watched \"Look at this Instagram (Nickelback Parody)\""]
]
javascript
<script>
$(document).ready(function (){
event.preventDefault();
$.ajax({
type:"GET",
url:"/friends2/",
data: {},
success: function(b){
b = jQuery.parseJSON(b);
console.log(b) //returns null
for (var i = 0; i < b.length; i++) {
var friend = "";
friend = b[i][3]
friend += "\n";
$('.social').append(friend);
}
}
});
});
</script>
html
<div class = 'social'></div>