我为一个有3个AJAX调用的Joomla!组件开发了一个统计数据。整个应用程序在本地完美运行,但是当我在实时服务器上测试它时,AJAX文件根本不起作用。它们在通过组件或直接调用时返回 500。
我的本地应用程序:Wamp Server
服务器:DirectAdmin
实时 AJAX 网址:
http://spaline.pc-games.co.il/administrator/components/com_product/views/reports/funnel.ajax.php?callback=5
和
http://spaline.pc-games.co.il/administrator/components/com_product/views/reports/callback.php?callback=cart-filling&date=5
和
http://spaline.pc-games.co.il/administrator/components/com_product/views/reports/filters.php?box_id=5&filter=grey
另外关于 AJAX 文件的路径,我这样定义它们:
define( '_JEXEC', 1 );
// defining the base path.
if (stristr( $_SERVER['SERVER_SOFTWARE'], 'win32' )) {
define( 'JPATH_BASE', realpath(dirname(__FILE__).'............' ));
} else define( 'JPATH_BASE', realpath(dirname(__FILE__).'../../../../../../' ));
define( 'DS', DIRECTORY_SEPARATOR );
// including the main joomla files
require_once ( JPATH_BASE.DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE.DS.'includes'.DS.'framework.php' );
// Creating an app instance
$app = JFactory::getApplication('site');
$app->initialise();
jimport( 'joomla.user.user' );
jimport( 'joomla.user.helper' );
...
我检查了路径,没有 404 错误。问题出在我的 AJAX 文件上。我不知道我定义Joomla的方式是否!标头正在制造此问题,或者问题出在 AJAX 函数本身左右。
问题出在文件路径上。我是这样想通的:
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../../../..' ));
// including the main joomla files
require_once ( JPATH_BASE . '/includes/defines.php' );
require_once ( JPATH_BASE . '/includes/framework.php' );
require_once ( JPATH_BASE . '/configuration.php' );
// Creating an app instance
$app = JFactory::getApplication('site');
$app->initialise();
jimport( 'joomla.user.user' );
jimport( 'joomla.user.helper' );
...