如何在ajax中读取此数组? 你能看一下这个服务器响应:
Array
(
[success] => 1
[0] => Array
(
[0] => Mr Green
[FirstName] => Mr Green
[1] => Hulk
[LastName] => Hulk
[2] => 30
[Age] => 30
)
[1] => Array
(
[0] => Mrs Green
[FirstName] => Mrs Green
[1] => Hulk
[LastName] => Hulk
[2] => 28
[Age] => 28
)
)
这是我的ajax成功
success: function(data){
if(data.success == true){
$("#output2").append("<p>"+ data.FirstName +"</p>");
}
}
如何正确循环?感谢。
答案 0 :(得分:0)
试试这个:
if(data.success == true){
$.each(data,function(k,v){
if (typeof(v.FirstName) != "undefined"){
$("#output2").append("<p>"+ v.FirstName +"</p>");
}
});
}