I've some jQuery code sending data through an AJAX call to a PHP script.
Data consists of an object with two properties.
One of the properties is a string, obtained by JSON.strinfigy(arrayofobjects) an array of objects.
Each object in arrayofobjects contains 3 properties, each being a simple string.
The number of objects in arrayofobjects is variable based on some user actions.
The problem is: when arrayofobjects exceeds the number of 25 objects the AJAX call fails and returns 403 Forbidden, so any debug is impossible.
It seems like the string resulting from JSON.stringify and sent through AJAX ovverides a maximum length.
The web server is Apache2 running on Ubuntu 18.04. Not using any PHP framework.
What I have tried:
- Apache mod_security module is not active
- In php.ini: display_errors = On, log_errors = On and error_reporting = E_ALL
- Set write permissions for every user on apache2/error.log
- Regular working apache2/error.log, but no trace of AJAX-related issue, no trace of any
403error - URL of called script is correct
- It's not a cross-domain call
- File permissions are OK since the script is called successfully in other instances and when
arrayofobjectscontains less than 25 elements - I can access the called page directly through http
- Increased
max_input_varsvalue inphp.ini
The structure of AJAX call:
$.ajax({
url: "ajax/called_page.php",
type: 'post',
data: {action: "post_duty", content: JSON.stringify(arrayofobjects)},
dataType: "json",
success: function(data) {
do some DOM manipulation
}, error: function() {
alert('Contact webmaster');
}