The code below is supposed to grab the ?cs=bla&cat=bla values from the link attribute and post it to my .load query…does anyone know where i am going wrong?
//Remove tab info and add gallery
$(".more").click(function () {
var $gallery = $(this).closest('.tab').find('.gallery-holder'),
cat = $(this).attr('href').split('cat=')[1];
if ($gallery.is(':empty')) {
$gallery.load('/public/themes/lbd/js/imagegallery.php', {'cat': cat}, function(){
$(this).fadeIn(function(){
$('a.customGal').zoomimage();
});
});
}
$gallery.siblings().fadeOut(function(){
$gallery.fadeIn();
});
return false;
});
Where your approach goes wrong is the split, when you do this:
.split('cs='), you’re not getting"bla"as the result, you’re getting"bla&cat=bla", the rest of the string.You could just pass the data as the same string if it’s in a known format (the original querystring pairs), like this:
Note this would produce a GET request rather than a POST (which happens then
.load()gets an object as thedataargument).