I'm working on a small application that has many AJAX requests being made to one file in particular.
Once the request is received, I would like the PHP action file to log where the request is coming from and make further decisions. In the PHP action file, I tried using
$origin = $_POST['origin'];
echo $origin; // returns either 'form-submit.js' or '/path/form-page.php'
Without adding another parameter to your Ajax request, the closest thing you can get to what you're looking for is to use
$_SERVER['HTTP_REFERER'] in PHP to get the value of the
Referer header which says what page the user was coming from.
Of course this value can't be trusted, can't be guaranteed it will be present (some may disable it) or relied upon in general.
You're better off adding another parameter to your request, but this of course can be modified client side too.