RoR 中的 AJAX 请求和 CookieOverflow
我正在制作一个动态清单,但在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要么在会话中存储更少的内容,要么将会话存储移动到 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.