admin管理员组文章数量:1419583
Guys, I'm having a trouble with a cookie.
The error:
"linhaOS" isn't defined.
I wanna know if the cookie is null in the beggining of code.
$("#pApresentacao").click(function _click(){
if ($.cookie("exibir") == null)
{
if ($("#hdLinhaOsView").val() != ""){i=$("#hdLinhaOsView").val()}
else {i=0};
$.cookie("exibir",1);
$.cookie("linhaOS",i);
_apresentacao(i);
}
else
{
if ($.cookie("linhaOS") == null){i=0}
else{i=$.cookie(linhaOS)};
_apresentacao(i);
};
The first cookie(exibir) is working fine. But the second is not! How is it possible? It is almost the same.
Could someone help me?
Thks folks.
Guys, I'm having a trouble with a cookie.
The error:
"linhaOS" isn't defined.
I wanna know if the cookie is null in the beggining of code.
$("#pApresentacao").click(function _click(){
if ($.cookie("exibir") == null)
{
if ($("#hdLinhaOsView").val() != ""){i=$("#hdLinhaOsView").val()}
else {i=0};
$.cookie("exibir",1);
$.cookie("linhaOS",i);
_apresentacao(i);
}
else
{
if ($.cookie("linhaOS") == null){i=0}
else{i=$.cookie(linhaOS)};
_apresentacao(i);
};
The first cookie(exibir) is working fine. But the second is not! How is it possible? It is almost the same.
Could someone help me?
Thks folks.
Share Improve this question asked Jan 17, 2011 at 16:16 ThiagoThiago 1,5653 gold badges25 silver badges40 bronze badges3 Answers
Reset to default 3Your problem isn't $.cookie(...)
it's that the variable linhaOS
is not defined.
else{i=$.cookie(linhaOS)};
^-------- If you use a variable you have to defined it
but this one doesn't appear anywhere in your code
So how to fix it? Well I suppose you wanted to use $.cookie("linhaOS")
once again, and you just forgot to quote it as a string with ""
. So just quote it as a string, that will fix your problem.
It looks like you forgot to wrap linhaOS
in string delimiters. Change
else{i=$.cookie(linhaOS)};
to
else{i=$.cookie("linhaOS")};
Looks like the statement that reads the cookie should be reading the string "linhaOS"
and not the variable linhaOS
.
本文标签: javascriptCookie problemcookie39s not definedStack Overflow
版权声明:本文标题:javascript - Cookie problem - cookie's not defined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745316847a2653194.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论