I am running a Joomla 4 website. I have a jBridge.php file that has the following:
use Joomla\CMS\Factory;
$session =& Factory::getSession();
$document =& Factory::getDocument();
$user =& Factory::getUser();
$jdb = Factory::getDbo();
Inside my custom module I can use:
include("libraries/JBridge.php");
$jdb->setQuery("SELECT * FROM example_table");
And this all works fine. But when I try the same technique in my custom component as part of an AJAX call, I get an internal server error shown on the network tab of my browser.
From Googling I've found that I need to include a combination of the following:
include ("../../../../includes/defines.php");
include ("../../../../includes/framework.php");
This stops the internal server error on my AJAX call, but then no data is being returned in the response section on the network tab of my browser. Even if I just echo out "test".
I'd really appreciate it if anyone could offer any advice or point me in the right direction please?
Thanks.