javascript - Cookie problem - cookie's not defined - Stack Overflow

Guys, I'm having a trouble with a cookie.The error: "linhaOS" isn't defined.I wanna

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 badges
Add a ment  | 

3 Answers 3

Reset to default 3

Your 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745316848a4622259.html

相关推荐

  • javascript - Cookie problem - cookie's not defined - Stack Overflow

    Guys, I'm having a trouble with a cookie.The error: "linhaOS" isn't defined.I wanna

    10小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信