Reputation: 49
I am using the jQuery load function to load a url into a div. Once that has successfully loaded, i want to load another url directly underneath the previous loaded content.
My html
<div id=content></div>
My jquery
$('#content').load('first_content.php', null, function() {
$('#content').append().load('second_content.php');
});
The issue is that the second loaded content, completely replaces the first loaded content.
How can i append content after the first_content is loaded, so that it appears underneath?
thanks
Upvotes: 0
Views: 1345
Reputation: 707328
Load the first block. When that completes, create a div and load the second block into that. When that one completes append the div into the content area.
$('#content').load('first_content.php', null, function() {
$("<div>").load('second_content.php', function() {
$(this).appendTo("#content");
});
});
Upvotes: 0
Reputation: 1576
Actually you're replacing #content content , try appending a new div with second content loaded.
$('#content').load('first_content.php', null, function() {
$('#content').append($('<div/>').load('second_content.php'));
});
Upvotes: 3