【问题标题】:Wrong page returned using jQuery.get()使用 jQuery.get() 返回的错误页面
【发布时间】:2013-09-30 20:43:06
【问题描述】:

我正在使用 Joomla 2.5 和 JA K2 过滤器和搜索组件。我正在尝试修改模块。当我选择一个类别时,它应该显示另一个名为 custom.html 的文件。

<script type="text/javascript">
jQuery(document).ready(function() {
    //disable the dynamic select list
    jQuery('#extraList').attr('disabled', 'disabled');
    //hide the dynamic select list
    jQuery('#extraList').hide();

    WireEvents();
});

function WireEvents() {
    jQuery('#category_id').change(function() {
        var value = jQuery('#category_id').val();
        if (value > 0) {
            //show the dynamic list
            jQuery('#extraList').removeAttr('disabled');
            jQuery('#extraList').show();

            jQuery.get("<?php dirname(__FILE__) . '/' . 'custom.html'; ?>",
                    function(data) {                             
                        jQuery('#outPutDiv').html(data);
                    }
            );

        } else {
            //disable the dynamic list
            jQuery('#extraList').attr('disabled', 'disabled');
            //hide the dynamic list
            jQuery('#extraList').hide();
        }

    });
}
</script>

问题是,不是返回custom.html而是返回主页?我该如何解决? 这是一些截图:

【问题讨论】:

    标签: jquery joomla2.5


    【解决方案1】:

    根据 PHP 文档dirname() 只返回父目录的路径。但是 iirc 模块位于 joomla_root/modules/module_name 中,而您的请求中缺少这些模块。您可以手动添加缺少的路径,也可以为此使用 Joomla 的常量(JPATH_SITE . '/modules/module_name/dirname(__FILE__)' 应该可以工作 iirc)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-02
      • 2019-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-03
      • 1970-01-01
      相关资源
      最近更新 更多