2013-12-16 30 views
1

以下是我想使用Js helper设置的回调函数,但是我找不到任何关于此的信息或示例。使用Js helper在CakePHP中设置成功回调

success: function(data) { 
    $('#EventProjectId').html(data.html); 
} 

这里是Ajax调用我有现在:

$this->Js->get('#EventCustomerId')->event('change', 
    $this->Js->request(array(
     'controller'=>'events', 
     'action'=>'getbycustomer' 
     ), array(

     'update'=>'#EventProjectId', 
     'async' => true, 
     'method' => 'post', 
     'dataExpression' => true, 
     'data' => $this->Js->serializeForm(array(
      'isForm' => true, 
      'inline' => true 
     )) 
     ) 
    )) 
    ); 

任何帮助深表感谢。

回答

2
$this->Js->request(array(
     'success' => "function(data) { 
      $('#EventProjectId').html(data.html); 
     }", 
     'controller'=>'events', 
     'action'=>'getbycustomer' 
     ), array(

     'update'=>'#EventProjectId', 
     'async' => true, 
     'method' => 'post', 
     'dataExpression' => true, 
     'data' => $this->Js->serializeForm(array(
      'isForm' => true, 
      'inline' => true 
     )) 
     ) 
    )) 
    );