0

ビューに ajax 経由でアイテムのリストをロードしたい ここに lst.cpt のコードがあります

<div id='benpane' class='clearfix'>
  <script type="text/javascript">
  <?php echo $ajax->remoteFunction(array(
    'url'=>array('controller'=>'benefits', 'action'=>'display'),
    'update'=>'benpane',
    'indicator'=>'benIndicator'
  )); ?>
  </script>
</div>

これが私のコントローラーのlst関数です

function lst() {
        $this->paginate = array('order' => array('ben_name' => 'ASC'),'conditions' => array($this->Benefit->parseCriteria($this->passedArgs)));
        $benefit = $this->paginate('Benefit');
        $this->set('bens', $benefit);
      }

ビューを開こうとすると、エラーが発生します

Error: Call to a member function remoteFunction() on a non-object   
File: /var/www/hassportal/app/View/Benefits/lst.ctp 
Line: 14

私は何が間違っているのでしょうか?

4

2 に答える 2

1

Ajax Helper が廃止された (および/または Cakephp 2.x を使用していない) という事実に加えて、間違ったアクションを呼び出しているようです:

'action'=>'display'

次のようにする必要があります。

'action'=>'lst'

また、そのアクションからのデータで更新されるはずの DIV の外にコードを移動します。

于 2013-10-08T18:06:33.933 に答える
0

これを使って

$this->Ajax->remoteFunction

$ajax->remoteFunction

元:-

<?php echo $this->Ajax->remoteFunction(array(
    'url'=>array('controller'=>'benefits', 'action'=>'display'),
    'update'=>'benpane',
    'indicator'=>'benIndicator'
  )); ?>
于 2013-11-20T12:14:49.980 に答える