doutao5499 2015-07-13 07:29
浏览 154

带有ajax的Jquery cookie增加了http请求大小

I made an online survey questionnaire which uses ajax to validate and Jquery cookie to store data. When a user fills the questionnaire, the cookie will store the question id, answer id and the comments one by one in the ajax success function. It also increases the http request size and once it crosses size 8k, the site will get stuck. Then I have to delete some comments to reduce the request size. I will post my ajax code here.

function ajaxEx(){
    $.ajax({
        url: 'submit_rep.php',
        type: "POST",
        data: 'aid='+a_id+'&js_cli='+js_cli,
        success:function(data) {
           Cookies.set(""+qid+"", [a_id,textarea],{ expires: 1, path: '/' });
        //here the cookies store questionid answerid and the comments.
        }
    });
 }

Kindly provide me some solution to solve this issue associated with http request. Thanks

  • 写回答

1条回答 默认 最新

  • dongxing1412 2015-07-13 07:39
    关注

    Cookies are not the right mechanism to store that kind of information; the size of a cookie is limited (4k) and you can only store about 20 cookies per site in the browser although that information might be a bit out of date by now. And as you noticed they get sent with every browser request.

    Either way, if you want to store information on the client side, you should look into local storage and if you need it on the server side, you should use a session (temporary) or something like a database for more permantent storage.

    评论

报告相同问题?

悬赏问题

  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常