I'd rather call $this->getRequest()->isXmlHttpRequest() if I want to know if the currently executed action is an ajax call. A preExecute() method making this variable protected viewable for the whole object is just neccessary if I want to check it on every action (than it safes time - otherwise: not).
But I think this snipped is a good help for any ajax newbie who want's to know how he can find out whether the action is called by ajax or not (I use ajax but I have not yet seen that method!) ;) So, thank you!
Comments on this snippet
I'd rather call
$this->getRequest()->isXmlHttpRequest()if I want to know if the currently executed action is an ajax call. A preExecute() method making this variable protected viewable for the whole object is just neccessary if I want to check it on every action (than it safes time - otherwise: not).But I think this snipped is a good help for any ajax newbie who want's to know how he can find out whether the action is called by ajax or not (I use ajax but I have not yet seen that method!) ;) So, thank you!
Yes, thank you ! Didn't found it in documentation