0
我想使用的getJSON呼叫等存储在cookie中这种”中的getJSON呼叫使用cookie的值
$.getJSON("cfc/getMember.cfc?method=getUser&returnformat=json&queryFormat=column",{"memberID":userID}, function(res,code)
的用户ID - 所以我想我会简单地使用:
function checkCookie(){
var userID=getCookie("UID");
}
现在(因为我敢肯定你会告诉我)我是新来的JavaScript,这可能是我的问题 - 但我在如何在getJSON调用中使用cookie值的一些建议。
谢谢!
西蒙
感谢卡尔文 - 我有var userID = getCookie(“uid”);作为检查cookie功能的一部分 - 你是否说我需要重复它?谢谢。 – Simon 2012-03-08 05:47:29
如何使用jQuery获取cookie:http://stackoverflow.com/questions/1599287/create-read-and-erase-cookies-with-jquery – Dror 2012-03-08 05:48:25
@Simon,你只需要声明你的'userID'变量在调用'$ .getJSON()'方法之前,不要将未声明的变量插入为“memberID”。 – Calvin 2012-03-08 06:01:16