0
define( '_JEXEC', 1 );
define( 'JPATH_BASE',$_SERVER['DOCUMENT_ROOT']);
$mosConfig_absolute_path = dirname( __FILE__ );
define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'methods.php');
require_once ( JPATH_BASE .DS.'configuration.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'base'.DS.'object.php');
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'database'.DS.'database.php');
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'database'.DS.'database'.DS.'mysql.php');
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'filesystem'.DS.'folder.php');

当 .php 文件位于根文件夹中时它可以工作,但是当我从子域调用它时出现错误:

XMLHttpRequest cannot load the php <my php file>. Origin <subdomain> is not allowed by Access-Control-Allow-Origin.

坦率地说,它有效(给我发一封电子邮件),但回调没有......

所以我将 php 文件移动到子域目录。现在我有 500 错误。需要帮忙。谢谢!

4

1 回答 1

1

所有域:

<?php 
   header('Access-Control-Allow-Origin: *'); 
?>

允许的域:

<?php 
   header('Access-Control-Allow-Origin: http://domain1.com, http://domain2.com'); 
?>
于 2013-07-30T12:42:25.263 回答