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端数据

  • 相关阅读:
    笔记75 微服务笔记2
    笔记73 高级SSM整合2
    笔记72 高级SSM整合
    笔记71 SSM整合
    笔记70 Spring Boot快速入门(八)(重要)
    笔记69 基于Redis的zSet集合做数据缓存实现分页查询
    如何理解多租户架构?
    Tomcat8.0源码编译
    HTML语言
    String类
  • 原文地址:https://www.cnblogs.com/xiami303/p/2876700.html
Copyright © 2011-2022 走看看