Is there a reliable way to find out if a request is in an Ajax context in PHP?

I need to deal with these two cases differently, is there a good solution?

+3
source share
2 answers
if ($_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') { /* ajax request */ }
+6
source

I can think of 2 ways to achieve this:

+3

Source: https://habr.com/ru/post/1732482/


All Articles