How to make AJAX call to myself from Joomla! module?
I wrote a module that is dependent on some third party device (load, parse & display). Sometimes it takes 5 seconds for it to respond so I tried to ajaxify this part.
My Joomla! module is ready as well as code with AJAX (mootools) but I can't figure out the URL to access my module php file "infused" by Joomla! (something like 开发者_JAVA技巧/index.php?option=com_content). I can hardcode and access it (/modules/mod_a/xyz.php) but I will run into "direct access not allowed" which is no trouble, but I don't have the Joomla! context which I pretty much miss.
All I found utilizes components which I would very much like to avoid.
Thanks for suggestions,
Regards,
Marek
You cannot access to your module by url. The only way to create very simple component with one model and one view for this purpose. Or you could add one task
to one the components installed in your site.
I did write the simplest component I could (no MVC):
defined('_JEXEC') or die('Restricted access');
$task = JRequest::getWord('task');
if ($task == "getCurrentTemp") {
// return temperature
}
This can be printed (heredoc) to JS by JURI::current()."index.php?option=com_xzy&task=getCurrentTemp". Not being able to access module sucks a little bit but I understand that from architectural point of view.
精彩评论