dougua2309 2015-07-07 15:50
浏览 51
已采纳

在jquery中通过.post()传递参数是否有限制

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().

My Question is:

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?

Example of working code

// 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");});      
    });
  • 写回答

2条回答 默认 最新

  • douyulv6921 2015-07-07 15:54
    关注

    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 size
    • upload_max_filesize which may be unrelated, not sure
    • max_input_time, if the POSt takes too long
    • max-input-nesting-level if your data is an array with a lot of sublevels
    • max_execution_time, but quite sure it's not that
    • memory_limit, as you may reach a size exceding the subprocess allowed memory
    • max_input_vars, if your data array has many elements

    Taken from: https://stackoverflow.com/a/9691395/2853903

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值