jQuery $ .each函数没有返回任何结果

Nit*_*ish -4 each jquery json

我的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"
            }
    }
]
Run Code Online (Sandbox Code Playgroud)

我试图提醒子位置的名称:

function render_ui(resp)
  {
    $.each(resp,function(index,obj){
      alert(obj.Sublocation.name);
    }

  }
Run Code Online (Sandbox Code Playgroud)

但是这个功能并没有提醒任何事情!什么原因 ?

ank*_*nkr 5

您有语法错误,您没有关闭调用 $.each

function render_ui(resp) {
  $.each(resp,function(index, obj) {
    alert(obj.Sublocation.name);
  });
}
Run Code Online (Sandbox Code Playgroud)