我目前正在将我的一个最新应用程序升级到 cakePHP 2.3,它包含很多 JavaScript/AJAX 内容。
我有以下代码:
function do_stuff() {
$html_content = $this->render('/elements/my_element');
$status = 'success';
$this->set('html_content', $html_content);
$this->set('status', $status);
$this->set('_serialize', array('html_content', 'status'));
}
我通过 AJAX 使用https://mydomain.tld/controller/do_stuff.json调用该函数
当然,我想接收一个带有 { 'html_content': '...', 'status': 'success' } 的 JSON 对象,
但我只收到 html_content。我认为,这是由于 $this->render() 调用造成的。
有人对此问题有提示/解决方案吗?