ajax怎么取一个json 数组
2个回答
2017-10-01
展开全部
1、先把得到的数组用alert(array)看是不是[object],如果不是如果是弹出这个数组的字符串的话;2、那就vararray=eval("("+array+")");再array[0]["title"]就能得到了。3、一般返回的如果不是json格式的数组,那么需要转换成json格式jQue
2017-10-01
展开全部
var data = {
"records":
[
{
"Name" : "Alfreds Futterkiste",
"City" : "Berlin",
"Country" : "Germany"
},
{
"Name" : "Berglunds snabbköp",
"City" : "Luleå",
"Country" : "Sweden"
},
{
"Name" : "Centro comercial Moctezuma",
"City" : "México D.F.",
"Country" : "Mexico"
}
]
};
var nameList = [];
for(var i = 0 ; i < data.records.length; i++ ){
nameList[nameList.length] = data.records[i].Name;
}
// nameList
"records":
[
{
"Name" : "Alfreds Futterkiste",
"City" : "Berlin",
"Country" : "Germany"
},
{
"Name" : "Berglunds snabbköp",
"City" : "Luleå",
"Country" : "Sweden"
},
{
"Name" : "Centro comercial Moctezuma",
"City" : "México D.F.",
"Country" : "Mexico"
}
]
};
var nameList = [];
for(var i = 0 ; i < data.records.length; i++ ){
nameList[nameList.length] = data.records[i].Name;
}
// nameList
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询