• Hi,

    I’m trying to use AJAX to update the comments list in a post. I want to return the generated HTML from wp_list_comments to Javascript so it can update the comments list. The AJAX call is called correctly, but my call always returns 0. Here’s the AJAX call:

    public function ajaxRefresh()
    	{
    		global $post;
    
    		wp_list_comments('callback=mytheme_comment&reverse_children=true');
    		exit();
    	} // function ajaxRefresh()

    I also tried putting ob_start() and ob_clean() around it, but that has the same result.

    Any suggestions?

    Thanks in advance.

    Cheers,
    Marco

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mrmastermindnl

    (@mrmastermindnl)

    Update:

    When I change the action hook from “init” to “wp”, I can get a response in a test, but not the wp_list_comments.

    Thread Starter mrmastermindnl

    (@mrmastermindnl)

    After some testing with the following code in my AJAX call:

    comments_template(get_bloginfo('template_url').'/comments.php');

    I can see that the function is called, but no result is returned. I think it has something to do with the the post or comment data not being available during the call.

    Any suggestions on that?

    Cheers,
    Marco

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘AJAX call wp_list_comments() in plugin’ is closed to new replies.