RoR 中的 AJAX 请求和 CookieOverflow

发布于 2024-12-24 23:33:39 字数 816 浏览 1 评论 0原文

我正在制作一个动态清单,但在 AJAX 请求和数据库更新方面遇到了一些问题。基本上,当单击某个项目时,我会异步更新数据库以表明已单击某个项目。这是 javascript:

    $('.checkBoxContainer').click( function() {
    $(this).css("background-color", "#FFF3D8");
    $(this).find("input").attr("disabled", "disabled")
    $(this).find("p").css("text-decoration", "line-through")
                     .css("color", "#AAA");
    $.ajax({
        type : "POST",
        url : "updateDone",
        data : "id=" + $(this).attr("id") 
    });
});

这是控制器中的方法

def updateDone
    currentItem = Item.find(params[:id])
    currentItem.update_attribute(:done => true)
  end

以下代码仅适用于 5 个项目左右,然后命令提示符会向我发送“Cookie 溢出”错误。我没有使用任何 cookie 或会话数据,那么这是如何产生此错误的呢?如果事实证明是 cookie 问题(尽管我不明白如何),我将如何清除服务器/浏览器中的会话/cookie 数据,以便客户端可以在清单上添加 5 个以上的项目?

I'm making a dynamic checklist and I'm having some problems with AJAX requests and database updating. Basically when an item is clicked, I asynchronously update the database to say that an item has been clicked. Here is the javascript :

    $('.checkBoxContainer').click( function() {
    $(this).css("background-color", "#FFF3D8");
    $(this).find("input").attr("disabled", "disabled")
    $(this).find("p").css("text-decoration", "line-through")
                     .css("color", "#AAA");
    $.ajax({
        type : "POST",
        url : "updateDone",
        data : "id=" + $(this).attr("id") 
    });
});

Here is the method in the controller

def updateDone
    currentItem = Item.find(params[:id])
    currentItem.update_attribute(:done => true)
  end

The following code works for only 5 items or so before the command prompt shoots me a "Cookie Overflow" error. I'm not using any cookie or session data so how is this producing this error? If it turns out to be a cookie problem (though I don't see how) how would I clear the session/cookie data in the server/browser so the client can make more than 5 items on the checklist?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜爱皱眉﹌ 2024-12-31 23:33:39

要么在会话中存储更少的内容,要么将会话存储移动到 memcache
默认的基于 cookie 的会话存储最多只能保存约 4kb 的数据,因为按照标准的 cookie 是不允许有更大的尺寸。

Either store less stuff in the session, or move the session store to memcache.
The default cookie based session store can only hold upto ~ 4kb of data, because cookies as per standard are not allowed to have a bigger size.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文