Symfony $request->isXmlHttpRequest() issue

后端 未结 3 960
情深已故
情深已故 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:14

    Some js libraries doesn't send the XmlHttpRequest value in the headers, juste add this in your script:

    xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");
    

提交回复
热议问题