【发布时间】:2012-06-22 18:08:25
【问题描述】:
我正在使用 $this->Js->submit 将值异步传递给我的控制器,而不是更新 div (id = #upcoming)。不知何故,我无法保存/检索传递给我的控制器的“测试”字段的值。 Firebug 告诉我传递了正确的值。我做错了什么?
查看文件(playlist.ctp):
echo $this->Form->create('Add', array('url' => array('controller' => 'Gods', 'action' => 'add')));
echo $this->Form->input('test');
echo $this->Js->submit('Addddd', array(
'url' => array(
'controller' => 'Gods',
'action' => 'add'
),
'update' => '#upcoming'
));
echo $this->Form->end();
echo $this->Js->writeBuffer(array('inline' => 'true'));
控制器动作:
public function add()
{
$this->autoLayout = false;
$this->layout = 'ajax';
$link = $this->request->data['Add']['test'];
$this->set('test',$link);
}
及其视图文件(add.ctp):
<?php
echo $test;
?>
感谢您的帮助!
【问题讨论】:
标签: php cakephp post xmlhttprequest