Symfony $request->isXmlHttpRequest() issue

后端 未结 3 968
情深已故
情深已故 2021-02-20 02:15

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

3条回答
  •  我寻月下人不归
    2021-02-20 03:03

    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.

提交回复
热议问题