所以我有一个分页的页面,我试图通过它们传递数据。在其他浏览器上,保存的值和路径是正确的。
数值:
{"introversion_extroversion":{"0":"71.43","1":"28.57","agree":"introversion","disagree":"extroversion"},"rationality_irrationality":{"agree":"irrational","disagree":"rationality"},"logic_ethics":{"0":"60.00","1":"40.00","agree":"ethics","disagree":"logic"},"intuition_sensory":{"0":"0.00","1":"100.00","agree":"intuition","disagree":"sensory"}}
路径:/
但是,在Safari上,路径与根目录不匹配(而是与分页页面匹配),并且值缺少符号。
数值:
{"introversion_extroversion":{"0":"71.43","1":"28.57","agree":"introversion","disagree":"extroversion"},"rationality_irrationality":{"agree":"irrationa
路径:test-page/page/3
我如何保存Cookie:
document.cookie = 'results=' + JSON.stringify(results) + '; path=/';
此外,控制台中也没有任何错误。
edit:在保存到cookie之前在控制台中打印出值,给出正确的值,这意味着一旦保存到cookie中,它就会出错。
1条答案
按热度按时间r3i60tvu1#
看起来你并不关心你的WordPress服务器是否能看到这些值。在这种情况下,你可能应该使用session storage而不是cookie来实现这个目的。(它在所有浏览器上都有效。)
要存储值:
要检索值:
这样可以存储更多信息。