Reputation: 177
I searched for an answer in many related questions and none of them actually fix my problem, so I have this code:
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
}else{
echo("This page can't be accessed.");
}
I tried renaming HTTP_X_REQUESTED_WITH
to HTTP_X_REQUEST_WITH
, because of another questions answer I saw that sometimes the request is sent as HTTP_X_REQUEST_WITH and not HTTP_X_REQUESTED_WITH
.
but none of those worked, which is quite strange since it worked a few days ago...
Upvotes: 0
Views: 2452
Reputation: 10371
The HTTP_X_REQUESTED_WITH
has been changed to X_REQUESTED_WITH
for major modern browsers.
Note that some browsers may still use HTTP_X_REQUESTED_WITH
.
Upvotes: 0
Reputation: 180004
AJAX requests don't automatically get HTTP_X_REQUESTED_WITH headers.
jQuery and most other libraries send it, but if you've rolled your own AJAX, you need to roll your own HTTP_X_REQUESTED_WITH headers.
Upvotes: 1