开发者

jQuery cookie issue

I am using this function to get a cookie and write its value on an hidden field:

//WE NEED TO SET THE COOKIE IMMEDIATELY
var tuitting_cookie = $.cookie("tuittingID");
$("#tuittingID").val(tuitting_cookie);

The problem is that the Cookie is generated in the same page where this jQuery cookie function is.

So at the very first load of the page the cookie is not yet available.

What I need to do is maybe set up a time out function that will check the cookie every second and will write the value in that field as soon as the Cookie becomes available in the browser..

How can I do it? IS there a better solution..

Let me know

Thanks very much!!

P.S the cookie is generated by a PHP function. I cannot directly generate the cookie with jQuery. So I just need a way to check the cookie every second and write the cookie in开发者_开发知识库 that field as soon as the cookie becomes available in the browser.

Thanks again!


Wrap that code in a function and add it as a callback to when you set the cookie.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜