JS-cookie always returns undefined

Hello, I am stuck in a situation and I cannot get JS-Cookie v2.1.3 to work as expected. I think there are some problems with the browser in this question, but I can’t pinpoint it, so I want someboduy to give some light. My goal is to set the language cookie on my website, I have the following code:

 jQuery(document).ready(function($) {

    $('#botEn').click(function(e) {
      Cookies.set('idioma', 'en', {
        expires: 7,
        path: '/'
      });
      $('.alert').html('<p>Btn english >> cookie:'+Cookies.get('idioma')+'</p>');

    });

    $('#botEs').click(function(e) {
      Cookies.set('idioma', 'es', {
        expires: 7,
        path: '/'
      });
      $('.alert').html('<p>Btn espaΓ±ol >> cookie:'+Cookies.get('idioma')+'</p>');
    });

});

https://jsfiddle.net/faridsilva/vrqvLfk2/18/

Mi violin showing a problem

This code only works in chrome (my version is 56.0.2924.87 64-bit), but firefox 51.x and safari 10.x always return "undefined"

The same thing happens to me with the example of Dustin Simpson in his violin , which, according to him, works perfectly in response to this question .

Dustin Simpson violin

+4

Source: https://habr.com/ru/post/1671026/


All Articles