+ 11

PHP file only for AJAX

Hi, Is there any way to declare that some PHP file is used only for AJAX and that it cannot be rendered in client browser when he types its URL?

11th Jul 2020, 4:26 PM
Dominik Vladař
Dominik Vladař - avatar
1 Antwort
+ 1
Not possible. There is no way to detect what sent the request to the server. However, you can send an extra field ajax=true with the request. Then in your PHP <?php if(empty($_GET['ajax'])){ exit(0); } Note that this can not stop browser request that append ?ajax=true to the url
11th Jul 2020, 5:08 PM
Ore
Ore - avatar