我的回复如下json
:
[
{
"Sublocation":
{
"id":"1",
"name":"Beltola",
"location_id":"1"
}
},
{
"Sublocation":
{
"id":"2",
"name":"Ganeshguri",
"location_id":"1"
}
},
{
"Sublocation":
{
"id":"3",
"name":"Kahilipara",
"location_id":"1"
}
}
]
我正在尝试提醒子位置的名称:
function render_ui(resp)
{
$.each(resp,function(index,obj){
alert(obj.Sublocation.name);
}
}
但是这个功能并没有提醒任何事情!是什么原因?
答案 0 :(得分:5)
您遇到语法错误,而不是关闭对$.each
function render_ui(resp) {
$.each(resp,function(index, obj) {
alert(obj.Sublocation.name);
});
}
答案 1 :(得分:0)
function render_ui(resp) {
$.each(resp,function(i, val) {
console.log(val.Sublocation.name);
});
}