我正在循环从 Flickr 返回的 JSON。我期望以下内容会提醒0,1,2,3...
索引等,但它正在提醒id,server,farm,etc
$.each(data.photo, function(index,item){
alert(index);
});
编辑
顺便说一句我正在使用method=flickr.photos.getInfo
var Info = "http://api.flickr.com/services/rest/?method=flickr.photos.getInfo";
Info += "&api_key=" + "myapikey";
Info+= "&photo_id="+item.id;
Info += "&format=json";
Info+= "&jsoncallback=?";
$.getJSON(Info,loaded);
function loaded(){
$.each(data.photo, function(index,item){
//Trying to get number of JSON Object (I am getting the info for 52 photos)....
//I want to alert 0 through 52 here and do some further processing
});
}
编辑
正如工程师指出的那样,我不应该循环这个,而应该只是使用data.photo.....