I have two javascript files, call it
- test1.js
- test2.js
they are used to request data from the php file using the following:
var xmlhttp= new XMLHttpRequest();
xmlhttp.open("GET", "../forum/getSomething.php", true);
xmlhttp.send();
and I have a php file which is used to do some queries and return the encoded json obj back to one of the js files above, call it
- getSomething.php
my question is, how can I tell which file js is making the request to the php? Ultimately, I want to state a condition and do something like the this:
# inside getSomething.php
# conditional statements
if request from test1.js
do A
else if request from test2.js
do B
Any tips would be helpful, thanks
You can use
HTTP_REFERERwithHTTP_X_REQUESTED_WITHbut it can be tricky I’ll advice you can to identify eachjsrequest with IDExample
Then PHP