Tom*_*len 6 cookies jquery html-encode escaping
我正在使用这段简短的代码:
var d = itemID + "," + quantity;
var CookieData = $.cookie("storebasket");
if(CookieData == null || CookieData == "") {
$.cookie("storebasket", d, { path: '/', expires: 60 });
} else {
$.cookie("storebasket", CookieData + "|" + d, { path: '/', expires: 60 });
}
Run Code Online (Sandbox Code Playgroud)
但是,值ALWAYS将变为HTML编码.例如:
5%2C1
Run Code Online (Sandbox Code Playgroud)
5,1
Run Code Online (Sandbox Code Playgroud)
我尝试过unescape但没有运气:
$.cookie("storebasket", unescape(d), { path: '/', expires: 60 });
Run Code Online (Sandbox Code Playgroud)
还有什么想法吗?
bra*_*ler 10
jquery.cookie默认编码逗号.要覆盖它,只需:
$.cookie.raw = true;
Run Code Online (Sandbox Code Playgroud)
这个答案确实很有用:
但我实在看不出有什么问题。当您想在文档中使用它们时,可以取消转义它们。如果你想将它们存储在 cookie 中,它们就会被转义。
| 归档时间: |
|
| 查看次数: |
4789 次 |
| 最近记录: |