updroid / jquery-jstore

Automatically exported from code.google.com/p/jquery-jstore
1 stars 0 forks source link

toJSON or not toJSON? FF vs Chrome #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In Firefox $.jStore.get() always returns a javascript object.
In Chrome it returns a string until the page is refreshed at which point it 
then returns a javascript object.

When I grab a session from my webservice I do this:

// store_session function which
$.jStore.set("current_session", $.toJSON(current_session));

and immediately I do this:
// restore_session function which also updates 
// gui elements after login and on each page reload
current_session = $.jStore.get("current_session");

 Proposed solution:
 try {
    // Chrome... oh Chrome...
    current_session = $.evalJSON(current_session);
  } catch(err) {
    // Firefox :D
 }

Original issue reported on code.google.com by coola...@gmail.com on 22 Jan 2010 at 9:32

GoogleCodeExporter commented 9 years ago
The new 2.0 release should be calling out to the browser's JSON object (which, 
if it's not 
defined, will also include json2 parser to add the functionality) for all 
storage by default 
now, so this issue should be resolved.

Original comment by gars...@gmail.com on 7 Apr 2010 at 5:48

GoogleCodeExporter commented 9 years ago

Original comment by gars...@gmail.com on 7 Apr 2010 at 5:48