Is there a way to give jquery a path and it would return list of all subfolders in given path?
I have this, which returns all pics from the folder:
var folder = "photos/";
$.ajax({
url : folder,
success: function (data) {
$(data).find("a").attr("href", function (i, val) {
if( val.match(/\.(jpe?g|png|gif)$/) ) {
$('#links').append(
'<a href="' + folder + val + '" title="' + val + '">' +
'<img src="' + folder + val +'" class="photos"></a>'
);
}
});
}
});
Just need proper regexp for "ends with /"
Is there a way to give jquery a path and it would return list of all subfolders in given path?
Every webserver will return this information in a different format, and some will not return such information at all.
Just need proper regexp for "ends with /"
Ah, OK. Replace val.match(/\.(jpe?g|png|gif)$/)
with val.match(/\/$/)
and then it will look for a trailing /
character.
$
represents end of string. \/
is an escaped /
character because /
normally represents the beginning and end of the regex.
I think if you used regex tag and title you may have gotten this answer more quickly. :-)