jquery - Overwrite and save JavaScript variable values permanently -
i have javascript file object inside. i'm trying change object variable values using javascript file. if change values , close , reopen javascript file object inside, values revert original value.
is there way change object values , save them, when close , reopen file has new values instead of old ones.
javascript file object:
var datax = { temperature: 20, light_intensity: 40, button: 0, max1: 0, counter: 0 };
a second javascript file changes datax object values:
//temperature max = max / 655.34; max = math.round(max); datax.max1 = max; //changes datax object max1 value $('#temp').html(datax["max1"] + "°c");
you can use cookies or html5 storage. prefer second option in case.
https://github.com/carhartl/jquery-cookie
http://amplifyjs.com/api/store/
simple example amplify.
// first store object. amplify.store( "yourobject", { foo: "bar" } ); // retrieve it. var retrievedvalue = amplify.store( "yourobject" );
Comments
Post a Comment