嘿,我有一个 json_encode,我试图循环并显示输出,但它不工作,我没有输出 =/
这是我的 js 小提琴:http: //jsfiddle.net/Z4jTc/1/
有人可以解释为什么它不会循环吗?
代码:
var messages = {"1":["2","1","0000-00-00 00:00:00","testing once"],"2":["2","1","0000-00-00 00:00:00","testing twice :)"]};
for(var id in messages){
var read = messages[id][0];
var from = messages[id][1];
var sent_on = messages[id][2];
var content = messages[id][3];
document.write = 'test';
document.write = '<div class="message_info">';
document.write = '<b>From:</b> '+from+'<br/><br/>';
document.write = '<b>Sent On:</b> '+sent_on;
document.write = '</div><div class="message_content">';
document.write = content;
document.write = '</div> <br/><br/>';
}