How to find out if a request is an ajax request?

后端 未结 3 933
我在风中等你
我在风中等你 2021-02-11 02:41

I try to find out if a request to a PHP file is sent by ajax or not.

I googled it and read a whole a bunch of articles that suggest following method:

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-11 03:21

    There's no 100% way to detect if the request was made via ajax. Even if someone sends header with "X-Requested-With: XMLHttpRequest" you shouldn't rely on it.

提交回复
热议问题