【发布时间】:2010-01-22 03:57:38
【问题描述】:
如何在 cakephp 中检查 Ajax 请求?
【问题讨论】:
如何在 cakephp 中检查 Ajax 请求?
【问题讨论】:
取决于蛋糕的版本。
1.3.x:
$this->RequestHandler->isAjax();
2.x || 3.x
$this->request->is('ajax');
【讨论】:
var $components = array('RequestHandler');
$this->RequestHandler->isAjax()
您可以找到有关RequestHandler component here的更多信息
【讨论】:
这个问题是一个较老的问题,但以防万一有人像我一样遇到这个问题并使用 CakePHP 2:
RequestHandler::isAjax() 已弃用,请使用请求对象的$this->request->is('ajax');
更多信息here
【讨论】:
不使用组件你可以使用这样的东西:
$this->params['isAjax'];这将返回一个布尔值。
【讨论】:
这是描述whisch的方式是doc。自从我开始使用cakephp以来我一直在使用
if($this->RequestHandler->isAjax()){
//
}
【讨论】:
如果你只是想查看php端的功能,试试:
$this->log('some debug',LOG_DEBUG);
然后检查 app/tmp/logs/debug.log。
【讨论】: