Having some trouble with my code, it works fine on Localhost but not on Fasthosts server. Seems to be an access issue to a folder on the server, here are the debug messages:
GET (http://reggarockaboogie.co.uk/images/gallery/fld01/) 403 (Forbidden)
k.cors.a.crossDomain.send @ jquery.min.js:4
n.extend.ajax @ jquery.min.js:4
LoadGallery @ gallery.html:95
(anonymous function) @ gallery.html:86
j @ jquery.min.js:2
k.fireWith @ jquery.min.js:2
n.extend.ready @ jquery.min.js:2
I @ jquery.min.js:2
Check out my code below:
< script >
$(document).ready(function() {
LoadGallery($('a[data-albumid]:first').data('albumid'));
$("a").click(function() {
var dir_path = $(this).data("albumid");
LoadGallery(dir_path);
return false;
});
});
function LoadGallery(dir_path) {
$.ajax({
url: dir_path,
success: function(data) {
$(".image-container").empty();
$(data).find("a:contains(.jpg), a:contains(.png), a:contains(.jpeg)").each(function() {
this.href.replace(window.location.host, "").replace("http:///", "");
var file = dir_path + $(this).text();
$(".image-container").append($("<a href='javascript:;' class='thumb' data-src='" + file + "'><img src='" + file + "' title='Click to enlarge' alt='#'/></a>"));
if ($(".image-container").children("a").length === 30) {
return false;
}
});
$(".image-container").append("<strong><p>Click on a thumb nail to show a larger image.</p></strong>");
$(".thumb").bind('click', function() {
var Popup = "<div class='bg'></div>" + "<div class='wrapper'><img src='<img src=''/>" + "<label href='javascript:;' class='prev-image'>«</label><label href='javascript:;' class='next-image'>»</label><a href='javascript:;' class='close' title='Close'>Close</a>";
var Img = $(this).attr("data-src");
$("body").prepend(Popup);
$(".bg").height($(window).height() * 4);
$(".wrapper img").attr("src", Img);
$(".prev-image").bind('click', function() {
var prev = $(".image-container").find("img[src='" + Img + "']").parent().prev('a').find("img").attr('src');
if (!prev || prev.length === 0)
return false;
else {
$(".wrapper img").attr("src", prev);
Img = prev;
}
});
$(".next-image").bind('click', function() {
var next = $(".image-container").find("img[src='" + Img + "']").parent().next('a').find("img").attr('src');
if (!next || next.length === 0)
return false;
else {
$(".wrapper img").attr("src", next);
Img = next;
}
});
$(".close").bind('click', function() {
$(this).siblings("img").attr("src", "")
.closest(".wrapper").remove();
$(".bg").remove();
});
});
}
});
}; < /script>
@import url(http://fonts.googleapis.com/css?family=Varela+Round);
#nav {
float: left;
width: 20px;
margin: 10px 10px 20px 0px;
}
#nav, #nav ul {
list-style: none;
padding: 0;
}
#nav a {
position: relative;
display: block;
width: 105px;
padding-left: 10px;
margin: 3px 0;
text-decoration: none;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-variant: small-caps;
font-weight: bold;
color: #fff;
}
#nav a:link, #nav a:visited {
border-left: #00425E solid 10px;
color: #fff;
}
#nav a:hover, #nav a:active {
border-left-color: #fff;
background-color: #770709;
color: #fff;
}
#nav a#here {
border-left-color: #fff;
background-color: transparent;
color: #fff;
}
#nav ul {
margin-left: 20px;
}
<!-- remaining CSS and HTML codes for the page omitted -->