简体   繁体   English

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

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

I am trying to use Ajax to pass some data to php file from smarty template. 我正在尝试使用Ajax将一些数据从smarty模板传递到php文件。

In template in javascript: 在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);
                }
            });
        });
});

When I test it, I get this error in console: 测试时,我在控制台中收到此错误:

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

I tried to add: 我尝试添加:

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

in ajaxtest.php but still no luck... 在ajaxtest.php中,但仍然没有运气...

How do I make it work? 我该如何运作?

Version 4.7.6 X-cart Gold 版本4.7.6 X-cart金色

The possible reason is 可能的原因是

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

In this case add this code to your modules/Custom/.htaccess file 在这种情况下,请将此代码添加到模块/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