I have the following PHP script file.php in my Joomla site:
$user = JFactory::getUser();
$usr_id = $user->get('id');
If I run it directly, using in HTML:
include_once "file.php";
It will get the user id, no problem.
However, if run it through an Ajax request:
$.ajax({
url: "other.php",
...
Where other.php is:
include_once "file.php";
I get the error:
Fatal error: Class 'JFactory' not found in file.php on line 3
Why? Any help!?