I need to check if the request is ajax. $request->isXmlHttpRequest()
works fine, however if there is a redirect somewhere during the execution, this method will
If you arent redirecting to a different application in your project or another external uri just use forward instead if isXmlHttpRequest is true on the first request.
Well that method checks against the value of the X-Requested-with
header and in some browser implementations that header (or all original headers) are dropped/overwritten from the redirected request (FF to name one).
As a workaround you could use a variable in the request itself. You might be able to use the existing sf_format
infrastructure, but im not sure if that would work because im not familiar with how it works internally.