jquery+ajax +json调用,已有数据返回但取数据等于undefined
function QTContent() {
$.ajax({
async: false,
type: "GET",
url: "../ajax/ajaxSJ.ashx?t=3",
cache: false,
success: function(msg) {
$("#divQT").html("");
var b = "";
$.each(msg, function(i,n) {
//msg已取到数据
if (i < 7) {
var content = msg["_2"];//这里获取的值undefined,这是为什么呢?
b += " <table width='260' border='0' cellspacing='0' cellpadding='0'>";
b += " <tr><td width='95'><table width='95' height='74' border='0' cellpadding='0' cellspacing='0' class='kang'>";
b += "<tr><td align='center'><a href=#'><img src='http://localhost:5656/images/qltj-pic1.jpg' width='87' height='66' border='0' /></a></td>";
b += "</tr></table></td>";
b += "<td valign='top'><img src='http://localhost:5656/images/menu-line.gif' width='15' height='36' /></td>";
b += "<td width='155' valign='top'><img src='http://localhost:5656/images/menu-line.gif' width='135 height='9' /><br />";
b += " <span class='qdtj'>" + msg["_4"] + "</span><br />";
b += "<img src='http://localhost:5656/images/menu-line.gif' width='135' height='9' /><br />";
b += "<a href='#' class='m2'>" + content + "<br /></a></td>";
b += "</tr></table>";
b += "<table width='135' height='3' border='0' cellpadding='0' cellspacing='0'>";
b += "<tr><td><img src='http://localhost:5656/images/menu-line.gif' width='135' height='3' /></td> </tr> </table>";
}
});
$("#divQT").empty();
$("#divQT").append(b.toString());
}
});
$("#divQT").ajaxStop(function() { $(this).fadeIn(500); }); //结束ajax
}
JSON数据
[{"_0":"9","_1":"战争8","_2":"战争战争战争争","_3":"/Manager/Public/ADImages/201203141018194687lxfs.jpg","_4":"../vode","_5":"2011-2-10 0:00:00","_6":"管理员","_7":"2","_8":"0","_9":"王牌影视"},{"_0":"8","_1":"战争7","_2":"战争战争战争战争战争战争战争战争","_3":"/Manager/Public/ADImages/201203141018194687lxfs.jpg","_4":"../vode","_5":"2011-2-9 0:00:00","_6":"管理员","_7":"2","_8":"0","_9":"王牌影视"},{"_0":"7","_1":"战争6","_2":"战争战争战争战争战争战争战争战争","_3":"/Manager/Public/ADImages/201203141018194687lxfs.jpg