Joomla上的jQuery AJAX!适用于本地但在服务器上提供错误500

时间:2017-01-24 07:01:10

标签: php jquery json ajax joomla

我已经为Joomla开发了统计数据!具有3个AJAX调用的组件。整个应用程序适用于本地完美,但当我在实时服务器上测试时,AJAX文件根本不起作用。他们在通过组件或直接调用时返回500.

我的本​​地应用:Wamp Server 服务器:DirectAdmin 实时AJAX URL:

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的方式! header正在解决这个问题,或者问题出在AJAX函数本身左右。

1 个答案:

答案 0 :(得分:0)

问题在于文件路径。我这样想:

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' );
...