简体   繁体   中英

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.

In template in 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...

How do I make it work?

Version 4.7.6 X-cart Gold

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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