I'm getting data through JSON
$.getJSON('http://api.flickr.com/services/rest/'
+ '?format=json&method=flickr.photosets.getPhotos'
+ '&photoset_id=' + photoset_id + '&per_page=1000'
+ '&page=1' + '&api_key=' + apiKey
+ '&user_id=' + userId + '&jsoncallback=?',
function (data) {
var fullPhotoURL, flickrLink;
var images = [];
var basePhotoURL;
var fullPhotoURL;
$.each(data.photoset.photo, function (i, flickrPhoto) {
var basePhotoURL = 'http://farm' + flickrPhoto.farm
+ '.static.flickr.com/' + flickrPhoto.server + '/'
+ flickrPhoto.id + '_' + flickrPhoto.secret + "_b.jpg";
var fullPhotoURL = 'http://farm' + flickrPhoto.farm
+ '.static.flickr.com/' + flickrPhoto.server + '/'
+ flickrPhoto.id + '_' + flickrPhoto.secret + "_b.jpg";
images.push($("<img/>").attr("src", basePhotoURL));
});
$.each(images, function (index, img) {
img.appendTo("#photographs").wrap(("<div class='item'></div>"));
});
});
I want to append two a's (with href basePhotoURL & fullPhotoURL) to each .item div.
$(".item")
.append("<a href='" + basePhotoURL + "'.jpg' class='zoom' />");
$(".item")
.append("<a href='" + fullPhotoURL + "' class='flickr' target='_blank' />");
Problem is, when i put those in the second each function, those two a's get appended for every .item that is present in #photographs (divception :-)) (so, 300 items x 2 a's PER .item). When i put those two a's outside the last each function, i get an undefined error. by the way, don't mind the fullPhotoURL and basePhotoURL variables' values; they are not correct.
Thanks!