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