$.getJSON amd IE6
$.getJSON amd IE6
Hello all,
I am stuck!!!
Have done this code below to get some photo sets from flickr and populate them on a gallery page...
At first this paints the sets and their first image, and when clicking on the set link will call $.getJSON again to populate the rest of the images for the specific gallery...
This works well for IE7,8 FireFox3 and Chrome - but the second $.getJSON does not work for IE6 (I do not even get an error) - it just seems that IE6 is not interested to issue the $.getJSON request...
Here is the code:
-
<script type="text/javascript">
function buildGallery(val){
//this takes the link to the set and breaks it down to get the user and set ids to than query the json...
var user = val.split("/sets/")[0].replace("http://www.flickr.com/photos/","");
var setid = val.split("/sets/")[1].replace("/","");
$.getJSON("http://api.flickr.com/services/feeds/photoset.gne?set=" + setid + "&nsid=" + user + "&lang=en-us&format=json&jsoncallback=?",
function(data){
$.each(data.items, function(i,item){
if (item.description.split("<p>")[3]!=null){
$("#flickr_gallery_title").append("<div class=\"company_flickr_image\"><a target=\"_blank\" class=\"company_light_gallery\" href=\"" + item.media.m.replace("_m.",".") + "\"><img border=\"0\" src=\"" + item.media.m + "\" /></a><p>" + item.description.split("<p>")[3] + "</div>");
}else{
$("#flickr_gallery_title").append("<div class=\"company_flickr_image\"><a target=\"_blank\" class=\"company_light_gallery\" href=\"" + item.media.m.replace("_m.",".") + "\"><img border=\"0\" src=\"" + item.media.m + "\" /></a></div>");
}
if((i+1)%3==0){
$("#flickr_gallery_title").append("<div style=\"clear:both;\"><!-- EMPTY --></div>");
}
});
$("#flickr_gallery_title a.company_light_gallery").lightBox();
});
}
$(document).ready(function() {
$(".flickr_set").each(function(){
var user = $(this).children("h4").children("a").attr("href").split("/sets/")[0].replace("http://www.flickr.com/photos/","");
var setid = $(this).children("h4").children("a").attr("href").split("/sets/")[1].replace("/","");
$(this).append("<div class=\"flickr_set_image\" id=\"flickr_set_image" + user.split("@")[0] + setid + "\"><p>Loading gallery...</p></div>");
$(this).children("h4").children("a").attr("title",$(this).children("h4").children("a").attr("href"));
$(this).children("h4").children("a").attr("href","JavaScript:void(0);");
$(this).children("h4").children("a").attr("target","_self");
});
$(".flickr_set a").click(function(){
$(".flickr_set").fadeOut(function(){
$("#flickr_gallery_title").fadeIn();
});
$("#flickr_galleries").prepend("<div id=\"flickr_gallery_title\" style=\"display:none;\"><h4>" + $(this).html() + "</h4><p><a id=\"flickr_linkback\" href=\"JavaScript:void(0);\">Back to Galleries</a></p></div>");
buildGallery($(this).attr("title"));
$("#flickr_linkback").click(function(){
$("#flickr_gallery_title").remove();
$(".flickr_set").each(function(){
$(this).fadeIn();
});
});
});
//populate the gallery
$(".flickr_set a").each(function(){
var user = $(this).attr("title").split("/sets/")[0].replace("http://www.flickr.com/photos/","");
var setid = $(this).attr("title").split("/sets/")[1].replace("/","");
$.getJSON("http://api.flickr.com/services/feeds/photoset.gne?set=" + setid + "&nsid=" + user + "&lang=en-us&format=json&jsoncallback=?",
function(data){
var img = "";
$.each(data.items, function(i,item){
img = item.media.m;
if ( i == 2 ) return false;
});
$("#flickr_set_image" + user.split("@")[0] + setid).html("<img src=\"" + img + "\" />");
if($("#flickr_set_image" + user.split("@")[0] + setid + " img").height()>180){
$("#flickr_set_image" + user.split("@")[0] + setid + " img").css("width","auto");
$("#flickr_set_image" + user.split("@")[0] + setid + " img").css("height","135px");
}
});
});
});
</script>
Can anyone please help???
Cheers.