我需要遍历下面的 json,但下面的代码循环遍历我的 json 中的每个字符并显示“未定义”:(下面的 json 有什么问题吗???感谢您的帮助)
{"news_id":"1","news_title":"News Title One","news_date":"2012-03-20","news_pic":"album-bb[6].jpg","news_desc":"Here goes the news title one Here goes the news title one Here goes the news title one Here goes the news title one.","gallid":"3"}
{"news_id":"2","news_title":"News Title Two","news_date":"2012-04-14","news_pic":"174863_163190093755777_2032987021_q.jpg","news_desc":"News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two News Title Two.","gallid":"0"}
这是我在点击事件时触发的代码:
var phpNews;
var NewsObject;
$(document).ready(function () {
$("#btnNewsPage").click(function()
{
$.post("server/news.php",null,function(e){
NewsObject = e;
$.mobile.changePage("#NewsPage");
});
});
$('#NewsPage').live('pagebeforeshow',function(event, ui){
var list;
$.each(NewsObject, function(k,v){
list = v.news_title;
});
$("#displayNews").html(list);
});
})