Reputation: 4359
So...um, how can I load a specific DIV from a page loaded via ajax?
I have this working
$.get(url,function(content){
//ajax content here
});
there is a div called #content
from the page being loaded. I want to load that div into my div called #wrap
on the main page.
I was thinking something like this maybe
$("#wrap").load($(content).find("#content"));
Upvotes: 1
Views: 7578
Reputation: 6011
$("#wrap").load(url + " #content", data, function(text, data, xhr){alert("success!");});
Upvotes: 0
Reputation: 8700
Here is what I would do:
$.post('THE LINK',
function(data)
{
$('#wrap').html($(data).select('#content').html());
}
);
The fiddle: http://jsfiddle.net/mazzzzz/P77Ev/
Upvotes: 2
Reputation: 20371
jQuery.load()
already does that for you (look under 'Loading Page Fragments'). In your case, get rid of the call to $.get()
and use the following instead:
$("#wrap").load(url + ' #content');
Upvotes: 0
Reputation: 5150
Load can use a selector...
$('#wrap').load('ajax/test.html #container');
Pulled directly from the jQuery Documentation: http://api.jquery.com/load/
Upvotes: 5