zoukankan      html  css  js  c++  java
  • localstorage进行setItem,Chrome报DOM Exception

    "Error: An attempt was made to add something to storage that exceeded the quota.
        at Object.$.ajax.success (http://127.0.0.1:8001/static/seg/js/storage.js:29:34)
        at jQuery.Callbacks.fire (http://127.0.0.1:8001/static/js/jquery-1.7.2.js:1075:30)
        at Object.jQuery.Callbacks.self.fireWith [as resolveWith] (http://127.0.0.1:8001/static/js/jquery-1.7.2.js:1193:7)
        at done (http://127.0.0.1:8001/static/js/jquery-1.7.2.js:7538:14)
        at jQuery.ajaxTransport.send.callback (http://127.0.0.1:8001/static/js/jquery-1.7.2.js:8324:8)
        at Object.jQuery.ajaxTransport.send (http://127.0.0.1:8001/static/js/jquery-1.7.2.js:8332:7)
        at Function.jQuery.extend.ajax (http://127.0.0.1:8001/static/js/jquery-1.7.2.js:7719:15)
        at Project._setEventDictToStorage (http://127.0.0.1:8001/static/seg/js/storage.js:17:11)
        at HTMLDocument.<anonymous> (http://127.0.0.1:8001/analysis/Pirates/segmentation:71:16)
        at jQuery.Callbacks.fire (http://127.0.0.1:8001/static/js/jquery-1.7.2.js:1075:30)"
    

    在我用localstorage进行setItem时, chrome报出如上错误。这是一个DOM exception的错误~

    最终发现原来LocalStorage对于单条限制大小不能超过5M,(事实上2M的时候就已经setItem不成功了~~~囧);

    当初美好的想将一些数据存储到localstorage的思路现在出现了极大问题;

    localstorage只适合存储那些不怎么变化的数据,或者下次还能被再次使用的数据。对于经常需要变动的数据,还是直接从后台取才是王道。

     见博文:

    http://www.cnblogs.com/zjcn/archive/2012/07/03/2575026.html  localStorage兼容方案实现

    http://www.cnblogs.com/sniper007/archive/2012/10/30/2746299.html   浏览器本地数据(sessionStorage、localStorage、cookie)与server端数据

  • 相关阅读:
    微服务架构中的熔断 VS 股票市场中的熔断
    通过异常处理错误
    Java之GC 如何工作
    HBase学习笔记
    日志打印的正确姿势
    告别if/else连环写法
    下载resource下的excel文件
    get请求和post请求参数中文乱码的解决办法
    jquery基础
    45度炸队Alpha冲刺博客集
  • 原文地址:https://www.cnblogs.com/xiami303/p/2876700.html
Copyright © 2011-2022 走看看