I am making use of .post()
quite extensively in my CMS
application. The example of working code below passes 13 (the most in my application) parameters to the processing.php
file which works fine.
When the need requires the passing of more parameters I have simply made use of the action
form property which also works fine.
However, I have an application where there is a need to pass 38 variables including large strings, but at the same time perform a check on the action file
and if the check fails I need to fire off a js confirmation alert
to continue or cancel.
I am not quite sure how to fire the js confirmation alert
from the processing.php
file and how to return to the originating file with the information entered into the form intact should the user cancel.
I do however understand how to accomplish this if I make use of .post()
.
Are there any limitations in the number of parameters one should send to a processing.php
through .post()
as written below or is there another approach I should take to handle the above described problem? And if so what would you suggest?
// code element
$( "#updateDefaultCodeButton" ).click(function(){
var url = $('#updateDefaultCodeURL').val();
var code_font_family = $('#code_font_family').val();
var code_font_color = $('#code_font_color').val();
var code_font_weight = $('#code_font_weight').val();
var code_font_size = $('#code_font_size').val();
var code_bg_color = $('#code_bg_color').val();
var code_pad_t = $('#code_pad_t').val();
var code_pad_r = $('#code_pad_r').val();
var code_pad_b = $('#code_pad_b').val();
var code_pad_l = $('#code_pad_l').val();
var code_w_pad_t = $('#code_w_pad_t').val();
var code_w_pad_r = $('#code_w_pad_r').val();
var code_w_pad_b = $('#code_w_pad_b').val();
var code_w_pad_l = $('#code_w_pad_l').val();
var postit = $.post( url, {
code_font_family:code_font_family,
code_font_color:code_font_color,
code_font_weight:code_font_weight,
code_font_size:code_font_size,
code_bg_color:code_bg_color,
code_pad_t:code_pad_t,
code_pad_r:code_pad_r,
code_pad_b:code_pad_b,
code_pad_l:code_pad_l,
code_w_pad_t:code_w_pad_t,
code_w_pad_r:code_w_pad_r,
code_w_pad_b:code_w_pad_b,
code_w_pad_l:code_w_pad_l
});
postit.done(function( data ) {window.location.replace("../generator.php?returnto=manage/global-styles-manage.php");});
});
JQuery Ajax itself doesn't have any limits. The request size is limited on the server however trough various configurations which depend on your environment.
Apache:
LimitRequestBody
, around 2Gb by default, maybe greater for 64bits, check error logs for details.PHP:
post_max_size
which is directly related to the POST sizeupload_max_filesize
which may be unrelated, not suremax_input_time
, if the POSt takes too longmax-input-nesting-level
if your data is an array with a lot of sublevelsmax_execution_time
, but quite sure it's not thatmemory_limit
, as you may reach a size exceding the subprocess allowed memorymax_input_vars
, if your data array has many elementsTaken from: https://stackoverflow.com/a/9691395/2853903
The php.ini contains post_max_size
and max_input_vars
, both of which can affect the amount you can post to a page.
http://php.net/manual/en/ini.core.php#ini.post-max-size http://php.net/manual/en/info.configuration.php#ini.max-input-vars
You can adjust both if you find yourself above the limit (which will generate a warning in the errorlog).
38 variables should be fine though - max_input_vars
defaults to 1,000, and post_max_size
defaults to 2MB (I think) so your text strings would have to be very big.