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 return false. How else can I check if request is ajax in this case?
p.s. ajax is initiated by jQuery
I need to check if the request is ajax. $request->isXmlHttpRequest() works fine, however if
Share
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-withheader 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_formatinfrastructure, but im not sure if that would work because im not familiar with how it works internally.