jquery - How to save/persist and access data on client side in javaScript? -


how save/persist , access data on client side in javascript:jquery?

i using jstree component of jquery:javascript.

in bind() of jstree, after selection of node want save "data"

you might want localstorage.

you can store data on client machine this:

var data = { name: 'bob', age: 12 }; window.localstorage.setitem('person', data); 

then on different page in same domain, can retrieve data:

var data = window.localstorage.getitem('person'); 

please note though browser security settings disable localstorage might not work in situations.

some more reading here: https://developer.mozilla.org/en-us/docs/web/api/web_storage_api/using_the_web_storage_api

the other alternative use cookies.

document.cookie = "name=bob"; document.cookie = "age=12"; console.log(document.cookie); // displays: name=bob;age=12 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -