我有以下从 URL 收到的 JSON,我们在这里调用 URLwww.blabla.com/testjson
它返回:
[{"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"}
];
我想检索这个 JSON 并返回这个结果,但是我得到了 UNDEFINED,这是我的代码:
$.each("www.blabla.com/testjson", function(index, element) {
$('.result').append(element.Naam);
alert(element.Naam);
});
您还需要检查用户 cookie 是否为真,否则它不会返回任何内容,我不这样做,因为我使用 phonegap 和 jquery mobile。这可能是问题吗?