繁体   English   中英

Xcart:在模板中使用ajax调用-403禁止错误

[英]Xcart: Using ajax calls in template - 403 Forbidden Error

我正在尝试使用Ajax将一些数据从smarty模板传递到php文件。

在javascript模板中:

$(document).ready(function() {
$(".redeem-button").click(function(){
            var test = 'test';
            $.ajax({
                url: 'modules/Custom/ajaxtest.php',
                data: {test: test},
                type: 'POST',
                success: function (data) {
                    $(".apply-left").html(data);
                }
            });
        });
});

测试时,我在控制台中收到此错误:

POST http://localhost/xcart/modules/Custom/ajaxtest.php 403 (Forbidden)

我尝试添加:

require_once 'http://localhost/xcart/auth.php';

在ajaxtest.php中,但仍然没有运气...

我该如何运作?

版本4.7.6 X-cart金色

可能的原因是

aim-server[~/www/xcart_4_6_x]$ cat modules/.htaccess    
Deny from all

在这种情况下,请将此代码添加到模块/Custom/.htaccess文件中

Order Deny,Allow
<Files "*">
 Deny from all
</Files>

<FilesMatch "^ajaxtest\.php$">
 Allow from all
</FilesMatch>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM