KNP Paginator with Ajax Call pagination not working

1.6k Views Asked by At

Hello I am using KNP paginator for pagination on simple page It's working perfect. But When I impalement pagination on page which one load by ajax call then it's not working. I am loading html data in one div when user check the box. My code is here :-

Ajax Call :-

<script type="text/javascript">
$(document).on("click", "#f_o_content input:checkbox", function(evt){
    $.ajax({
        url: "abc_xyz",
        type: "POST",
        success: function(data) {
            $('#s_o_r_middle').html(data);
        }
    });
});

Controller :-

/**
 * @Route("/abc-xyz", name="abc_xyz")
 * @Template
 */
public function ajaxAction(Request $request)
{
    if ($request->isXmlHttpRequest()) {                             
        $results = $data;
        $paginator  = $this->get('knp_paginator');
        $pagination = $paginator->paginate(
                $results,
                $this->get('request')->query->getInt('page', 1),
                100
        );
        return $this->render('ABCBundle:ABCBlock:ajax.html.twig', array('entities' => $pagination));
    }
}

same pagination on other page is working perfect without ajax call but when I am load data with ajax call and click on pagination page then it's take ajax action url and page no.

Thanks !

0

There are 0 best solutions below