AJAX 403 forbidden when making ajax request

9.4k Views Asked by At

The website initiates ajax request but always get return 403 error for all browsers.

I tested it by initiating the same call in firebug console, it works (status: 200)

What is the problem can be deduced?

jQuery.ajax({ 
    url: "cart_ajax_get_product.php", 
    data: {id: 355, qty: 1}, 
    success: function(data) { }); }, 
    error: function(err) { } 
});

Thanks

2

There are 2 best solutions below

0
On
jQuery.ajax({ 
url: "cart_ajax_get_product.php", 
data: {id: 355, qty: 1}, 
success: function(data) {

}
error: function(err) { } 
});
0
On

Might be an issue related to apache mod_security. Try forcing the ajax request to GET instead of POST:

jQuery.ajax({ 
    type:"GET",
    url: "cart_ajax_get_product.php", 
    data: {id: 355, qty: 1}, 
    success: function(data) { }); }, 
    error: function(err) { } 
});

Or if that doesn't help...

You could try setting these options on the server's .htaccess, or configuring them elsewhere:

SecFilterScanPOST Off
SecFilterEngine Off