CakePHP Using requestHandler and isAjax [closed]
I have the following code (I'm also calling the RequestHandler component) in my con开发者_C百科troller:
function popup()
{
if ($this->requestHandler->isAjax())
{
// jazz
}
else
{
$this->cakeError('error403');
}
}
The idea is that if a user tries to access the page directly then they will get a 403 or if it's loaded in a popup via AJAX then all be fine. However I get the following errors:
Notice (8): Undefined property: PagesController::$requestHandler [APP/controllers/pages_controller.php, line 103]
Fatal error: Call to a member function isAjax() on a non-object in /Users/cameron/Sites/cameron/app/controllers/pages_controller.php on line 103
and line 103 is the if statement
Any ideas what the problem is? Thanks
$this->RequestHandler->isAjax();
Just a typo.
精彩评论