jquery-cookie

Using Bootstrap, have alert box remember close action

蹲街弑〆低调 提交于 2019-12-04 01:28:47
I am trying to create a Bootstrap alert box that remembers when users click the close button. I guess I need to store that information in a cookie. Ideally that cookie will only last for that current session, and next they return the box will appear again. I am using the jQuery-Cookie plugin. I uploaded it to /jquery-cookie-master . Plugin can be found here . This is what I've got so far by following code found here . <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script src="/jquery-cookie-master/jquery.cookie.js"></script> <script> function runOnLoad

jQuery AJAX Response Set Cookie Header

天涯浪子 提交于 2019-12-03 16:06:22
I have a project which using a a REST API. Here when Isend a login request, they are sending me the response as JSON containg some data. Along with that in Response Header Access-Control-Allow-Origin:* Connection:keep-alive Content-Length:239 Content-Type:application/json Date:Fri, 19 Oct 2012 06:28:12 GMT Server:Apache/2.2.22 (Amazon) Set-Cookie:session=username; Path=/ Here we have a Set-Cookie , but this cookie is not setting. I need this cookie to be setted, because for any other API access, the server will check for this cookie. How can I resolve this Issue? What is the solution for

(jQuery) Save checkbox state on click in cookie

谁说我不能喝 提交于 2019-12-03 00:32:26
There are a lot of topics regarding this function, nonetheless I can't seem to get it working. I've googled on this specific case and a bunch of links let me here, but strangly enough I can't seem to get them to work. The only thing I did get working was the following: http://dl.dropbox.com/u/2238080/a/!old/z.htm but as you can see, it doesn't store the state of the box is unchecked. Regards, Ruben You can change ALL your code to just: EDITED to remove part unneeded. $(document).ready( function(){ // read the current/previous setting $("input.box[type=checkbox]").each(function() { var name = $

Saving multiple panel's collapsed state using cookies with $.cookie()

随声附和 提交于 2019-12-02 20:33:44
I'm trying to determine how I might save a collapsible panel's collapsed state using $.cookie. This question has been helpful so far, but still missing the end solution. Any solutions I have found so far have only saved the last rolled down panel so when the page is reloaded the only panel saved is the last one. What I need is to save all panels that are rolled down rather than just one. Link to jCookie plugin on Github. Link to demo on JSFiddle UPDATE It has been suggested that LocalStorage is a more appropriate solution to what I am trying to achieve. If you can comment on why and what local

Cannot retain checkbox value using jquery.cookie

元气小坏坏 提交于 2019-12-01 14:12:02
I use jQuery DataTable and there is a checkbox on the toolbar that is used for retrieving all records or not. As stateSave feature of DataTable does not work properly, I tried to use jquery.cookie in order to keep the checkbox value after reloading the DataTable (because the checkbox is redrawn dynamically on every reload) as shown below: $(document).ready(function() { $('#example').DataTable( { //code omitted for brevity "serverSide": true, "ajaxSource": "/Student/GetStudents", "fnServerData": function (sSource, aoData, fnCallback) { /* Add some extra data to the sender */ aoData.push({ "name

How to read the cookie creation date (not expiration)

女生的网名这么多〃 提交于 2019-12-01 01:38:48
问题 Is there a way to store in a variable a cookie creation date? I'm using the jquery.cookie plugin. If there is not a way, I'm thinking about store in the cookie, as value, the actual time/date. It could be a solution. Thanks. 回答1: <!-- Output the DateTime that the cookie is set to expire --> @Request.Cookies["YourCookie"].Expires.ToString() However, I don't believe that there is a property to get the Creation Date, unless you were to specifically store the value itself as an additional value

jquery cookie set value to boolean true

╄→гoц情女王★ 提交于 2019-11-30 08:33:26
问题 I am using this jquery.cookie plugin and I need to set value to TRUE or NULL/FALSE. I am trying to do it like this: $.cookie('ff', true, { expires: 30, path: '/' }); but it sets the value to string and not boolean. Any ways of fixing this? 回答1: Cookies are only string-valued. As gdoron commented, if you want to treat the value as a boolean, you need to parse it back to a boolean when the cookie value is read back out. Since you commented that you are reading the cookie value with PHP, see

Create a cookie if (and only if) it doesn't already exist

自作多情 提交于 2019-11-27 21:57:35
I want to: Check to see if a cookie with name of "query" exists If yes, then do nothing If no, create a cookie "query" with a value of 1 Note: I am using jQuery 1.4.2 and the jQuery cookie plugin . Does anyone have any suggestions as to how I can do this? if($.cookie('query') === null) { $.cookie('query', '1', {expires:7, path:'/'}); } Alternatively, you could write a wrapper function for this: jQuery.lazyCookie = function() { if(jQuery.cookie(arguments[0]) !== null) return; jQuery.cookie.apply(this, arguments); }; Then you'd only need to write this in your client code: $.lazyCookie('query',

Create a cookie if (and only if) it doesn't already exist

浪子不回头ぞ 提交于 2019-11-26 20:56:09
问题 I want to: Check to see if a cookie with name of "query" exists If yes, then do nothing If no, create a cookie "query" with a value of 1 Note: I am using jQuery 1.4.2 and the jQuery cookie plugin. Does anyone have any suggestions as to how I can do this? 回答1: if($.cookie('query') === null) { $.cookie('query', '1', {expires:7, path:'/'}); } Alternatively, you could write a wrapper function for this: jQuery.lazyCookie = function() { if(jQuery.cookie(arguments[0]) !== null) return; jQuery.cookie

jquery, delete cookies

*爱你&永不变心* 提交于 2019-11-26 19:57:40
I want to use JQuery to delete cookies ; I tried this $.cookie('name', '', { expires: -1 }); Then I refresh the page and the cookie is still there : alert('name:' +$.cookie('name')); Why? Thanks Chadwick To delete a cookie with JQuery, set the value to null: $.cookie("name", null, { path: '/' }); Edit: The final solution was to explicitly specify the path property whenever accessing the cookie, because the OP accesses the cookie from multiple pages in different directories, and thus the default paths were different (this was not described in the original question). The solution was discovered