Ajax不能从应用程序的根文件夹访问UP目录下的文件


Ajax cant access a file inside directory UP from the app's root folder

我使用这个ajax调用:

<script>
jQuery(document).ready(function(){
  jQuery('#compare_btn').click(function(event){
    event.preventDefault();
    var id=jQuery('#compare_btn').attr('name');
    alert(id);
    jQuery.ajax({
      type:"GET",
      data:{'propid':id},
      url: "compareAjax.php",
      success:function(result){
        alert(result);
      },
       error: function(req) {
                alert('Error: ' + req.status);
      }
    });
  });
});
</script>

compareAjax.php只包含一个

echo "working";

当我使用url : compareAjax.php时,我将文件放在我的网站的根文件夹中,它按预期工作。

但是当我移动文件到:components/com_iproperty/views/compare/并将url修改为"components/com_iproperty/views/compare/compareAjax.php"我从ajax请求状态返回500错误。

认为我做过:

    从firebug,我检查了网络选项卡和请求URL从我把我的文件和文件夹都添加到www-data组
  • 在777
  • 更改了em的权限

这些都不起作用。我将文件移动到组件文件夹,并更改了ajax的url,但再次弹出500个错误。

似乎是一个服务器端问题,但不能找到什么。有人知道这是怎么回事吗?

尝试使用绝对路径,有时对我有帮助:

url: "/components/com_iproperty/views/compare/compareAjax.php",

按如下所示更改url属性

url: "components/com_iproperty/views/compare/compareAjax.php",