How to check an Ajax request in cakephp?

Viewed 26299

How to check an Ajax request in cakephp?

6 Answers
  • You need to enable the RequestHandler component

var $components = array('RequestHandler');

  • Then you check if its an ajax request in your controllers with:

$this->RequestHandler->isAjax()

You can find more information about the RequestHandler component here

Without the use of components you can use something like this:

$this->params['isAjax'];

This will return a bool.

If you simply want to check the function of the php side, try:

$this->log('some debug',LOG_DEBUG);

then check app/tmp/logs/debug.log.

Related