I'm using jQuery to hijack a link pointing to a php file. This php file is mostly html, but calls two php functions that each use a for loop to output html. The problem I'm running into is that the ajax call is incorrectly nesting the html generated by the php for loop.
Including the php file directly onto the page works fine, but when trying to grab it via ajax the html content of each sequential pass through the loop is inserted inside the previously generated html. For example:
<div>Content1</div>
<div>Content2</div>
<div>Content3</div>
becomes:
<div>Content1<div>Content2<div>Content3</div></div></div>
This is the relevant code for the php file:
<div class="publishedPosts">
<h3>Published</h3>
<?php displayPublishedBlogPosts(); ?>
</div>
<div class="verticalDivider"></div>
<div class="draftPosts">
<h3>Saved Drafts</h3>
<?php displayBlogPostDrafts(); ?>
</div>
And this is the jQuery code:
function adminPanelTabs() {
$('#adminPanelTabs ul li a').click(function(e) {
$('#adminPanelTabs ul li a.current').removeClass('current');
$(this).addClass('current');
$('#adminPanelContent').load($(this).attr('href'));
e.preventDefault();
});
}
Would appreciate any input or suggestions on how to fix this.
