Ajax call gets 403 Forbidden

I’m doing an ajax call to a small file located in the plugins folder. But when doing so I get the error [HTTP/1.1 403 Forbidden]

When I place the file in the root folder instead, it works.
Is there a way to change permissions so I can place the file with my plugin in my plugins-folder and call it there? Perhaps make an exception for just this file to be called?

This is a small file that will make periodic checks to check if any files and folders have changed, and if so, update the page.

Problem number 2 is that I don’t really know what namespace and such I have to place in this single ajax file to be able to access the built in functions of GRAV like Uri and such.

Right now the file is simply printing out text to test the call, but I want it to also be able to access the deeper functions of grav and still remain a small file since it will be periodically called in quite short intervals.

Thank you for you time.

I found the solution to half my problem by looking in the .htaccess file and commenting out the file RewriteRule ^(user)/(.*)\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ error [F]

But I would like to keep this rule and only make an exception for my specific file located in user/plugins/check.php

Typically you shoudln’t be calling .php even via ajax… call it with .json extension in the url and convert data to json with the |json_encode filter.

@rhukster
call it with .json extension
I have a php file that returns data from database in .json format. How would my ajax call look like?
--------------request = $.ajax({ url: "/data.php", type: "post", data: data, dataType: 'json', success: function (response) {}, error: function (request, status, error) {} }); ----------------
Of course this is giving 403 forbidden error, unless I put my php file in root folder.