How to check an Ajax request in cakephp?


  • You need to enable the RequestHandler component

var $components = array('RequestHandler');

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

$this->ResquestHandler->isAjax()

You can find more information about the RequestHandler component here

ALSO,

Depends on the version of cake.

1.3.x:

$this->ResquestHandler->isAjax();

2.x

$this->request->is('ajax');
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s