如果您尝试使用 ajax 调用访问模块,则正确的方法如下
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$Module = &JModuleHelper::getModule('mod_fmDataGrid');
$Params = "param1=bruno\n\rparam2=chris";//This will only required when you pass module params through code
$Module->params = $Params;
echo $renderer->render($Module);
更多_
如果您尝试从当前页面访问它,您已经像下面那样加载了框架,但这不是一个好习惯。
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
更多_
尝试对任何现有的组件控制器进行 ajax 调用,如下所示。
jQuery.ajax ({
type: "GET",
url: "index.php?option=com_virtuemart&controller=productdetails&ajax_request=1&task=addItemToWaitlist",
//controller components controller name
//task the function inside controller.
data: data,
success: function(data) {
alert(data)
}});