I need to load content from an external page when the user clicks on a tag:
$('#anchortag').click(function() {
event.preventDefault();
$('#recepient').hide();
$('#recepient').load('otherpage.php', function(data) {
$.fancybox(data, {});
});
});
I’m using the jQuery load() method to do so, but all I want is the fancybox to open with the external content while now, the content shows in the #recepient and in the fancybox. If I try to do: $.load (without specifying a target), it fails (the fancybox doesn’t show up and I guess the function doesn’t work..).
How can I only open the external content in the fancybox with load or another jquery function?
EDIT:
How come this script only works under Chrome and not FF or IE?
Use
$.get(..)instead.load(..)puts the content as innerHTML of the target object, and you don’t want that.