开发者

In cakephp,layout calling two times when i use AJAX

Please see below code sni开发者_Python百科ppt:

<?php
  //Sets the update and indicator elements by DOM ID
  $paginator->options(array('update' => 'content','indicator' => 'spinner','url' =>$this->passedArgs));

  echo $paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
  echo $paginator->next('Next >>', null, null, array('class' => 'disabled'));
?>

And my page url is http://total.projectsjunction.com/artists/portfolios/1

Now I have a problem.I am using AJAX based paging with cakePHP But when i click on next page it calling header and footer two times.

How I can call layout only one time if I use function two time with ajax.

kindly give your support.

Thanks


Something like this may help you:

if( $this->RequestHandler->isAjax() ) {
  $this->layout = false;
}

This will turn off the layout on an ajax request but leave it on otherwise. I believe this will be specific to a given request, but I haven't tested it and have never needed to do this myself.


This may help you get your situation squared away. It applies to CakePHP 1.2, but is hopefully a good starting point.

http://bakery.cakephp.org/articles/view/easy-ajax-pagination-using-jquery


try this one in beforeFilter() function, I am sure your problem will be solve.....

    if ($this->RequestHandler->isAjax())
    {
        Configure::write('debug',0);
        $this->header('Pragma: no-cache');
        $this->header('Cache-control: no-cache');
        $this->autoRender   =   false;
        $this->autoLayout   =   false;
       /*
          for disable layout you can also use
           $this->layout='';
           $this->layout=false;

        */

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜