我正在使用 cakephp 3.4
我有一个使用 ajax 提交值的表单。
<?= $this->Form->create(null, ['id' => 'search-form']) ?>
<?= $this->Form->control('keyword') ?>
<?= $this->Form->button(__('Search'), ['id' => 'search-submit']); ?>
<?= $this->Form->end() ?>
并将此数据发送到使用
$('#search-submit').click(function(event){
event.preventDefault();
$.post('/dashboard/custom-search/ajax-search',
{
data: $('#search-form').serialize()
}, function (response)
{
$('#search-result').html(response);
});
return false;
});
在ajaxSearch
我调试请求数据时起作用
debug($this->request->getData());
它给
[
'data' => '_method=POST&keyword=world'
]
但是当我尝试
debug($this->request->getData('keyword'));
它给
null
如何在操作中获取序列化数据?或如何反序列化动作/控制器中的数据?