I'm creating a module where in my main PHP file I've added a reference to a Javascript file. In that Javascript file, I do a jQuery call on dom ready that does an Ajax post to grab the initial content for a div. The URL that it posts to is another PHP file (gateway.php) that is part of my module. (This gateway.php does a call to a remote server to get the content.)
Well, direct access is typically prohibited for module files. I can comment out the line of code that prohibits direct access. Even doing that, for some reason it seems like my gateway.php doesn't have full access to everything in Joomla. For example, gateway.php has a require of my helper.php file. I'm just doing
require_once(dirname(__FILE__) . DS . 'helper.php');
which as far as I can tell is the standard way to include a file. However, I get errors showing that DS isn't getting translated as the value defined within Joomla. Its treating DS like a string value.
If I change it to
require_once(dirname(__FILE__) . '/helper.php');
then I get the direct access prohibited error.
Any idea what's going on here or the correct way to using Ajax in a Joomla module in a file other than the main PHP module file?