0

如何在 succesfull 数组中返回以下 json 数据:

    [{"Identifier":1,"Naam":"NOT Given","Adres":"Kopenhagen 9","Postcode":"0000LL","Plaats":"NOT Given","Longitude":"0.00000","Latitude":"0.00000"},
{"Identifier":2,"Naam":"NOT Given","Adres":"NOT Given 1","Postcode":"0000LL","Plaats":"Rotterdam","Longitude":"0.00000","Latitude":"0.00000"},
{"Identifier":3,"Naam":"NOT Given","Adres":"NOT Given 6","Postcode":"0000LL","Plaats":"Rotterdam","Longitude":"0.00000","Latitude":"0.00000"},
{"Identifier":4,"Naam":"NOT Given","Adres":"NOT Given 1","Postcode":"0000LL","Plaats":"Den Haag","Longitude":"0.00000","Latitude":"0.00000"},
{"Identifier":5,"Naam":"NOT Given","Adres":"NOT Given 218","Postcode":"0000LL","Plaats":"Zoetermeer","Longitude":"0.00000","Latitude":"0.00000"}]

我想在一个数组中调用它,例如 data.Naam 其中 id = 2。

如果您使用此代码:

$.post( "http://notGiven", {}, function(data) { 
        alert('Aantal elementen in lijst: ' + data.length); 
        $.each(data, function(index, element) {

            });
        });

那么数据长度给了我一个高于 3000 的数字,为什么。

如果我在循环中尝试 element.Naam,那么它会返回 undefined ......

所以..我如何获得我的 json 返回的数据,就像所有的名字一样?没有显示未定义的错误...

4

1 回答 1

0

正如@Utkanos 所说,

解决方案在这里:http: //jsbin.com/equkaf/6/edit

于 2012-08-14T13:58:16.343 回答