AJAX 403 forbidden when making ajax request

Ictuser Ai picture Ictuser Ai · Jan 28, 2013 · Viewed 8.5k times · Source

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

Answer

james picture james · May 5, 2014

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