Reputation: 427
Afternoon all,
Using the code below I'm trying to load what is render by the clicked link in to #loader, this works but I don't want the whole page I would like just a selected DIV i.e. #photo.
Whats the right way for this to be done?
$(function() {
$(".style_image a").live('click', function(event) {
$("#loader").load(this.href)
.show();
$.get(this.href, null, null, "script");
return false;
});
});
I've tried:
$("#loader").load('this.href', #photo)
and:
$("#loader").load(this.href #photo)
No success!
p.s. the #loader is originally hide in my css file.
Regards
Mr THOMAS
Upvotes: 0
Views: 134
Reputation: 22050
Try and use ('#element).attr('src','http://...');
it should work.
Thanks Jean
Upvotes: 0
Reputation: 630607
You can do it like this:
$("#loader").load(this.href + " #photo");
It needs to be part of the string, with a space in-between.
Also, I'd show it once loaded, like this:
$("#loader").load(this.href + " #photo", function() { $(this).show(); });
This prevents flicker of it showing then getting content in.
Upvotes: 3