WordPress.org

Forums

Loop within ajax-fetched fragment returns server error. (1 post)

  1. bobdobbs
    Member
    Posted 2 years ago #

    I've been testing towards conditionally delivering a sidebar.
    The sidebar contains a minimal testing loop that lists latest posts.

    If I include my loop code in a test page, it works just fine. This is the code I have:

    <section id="sidebar">
    <?php if ( have_posts() ) : while ( have_posts() ) :
    the_post(); the_title(); the_content();
    endwhile; endif; ?>
    </section>

    However, if I put this code into it's own file (sidebar.php) and then request sidebar.php via an ajax request from javascript, I get a bad result:

    In the resulting page source I can see <section id="sidebar">, but not the rest of the sidebar code.

    In firebug, I can see that the request has resulted in an internal server error. (I'm developing on apache)

    Why could this be going wrong?

    Is there something I need to know about loop code inside ajax fragments?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags