Skip to content Skip to sidebar Skip to footer

Getjson's Data : Clarification Needed

Given JSON containing: [ {'myKey':'A','status':0,'score':1.5},{'myKey':'C','status':1,'score':2}, {'myKey':'D','status':0,'score':0.2},{'myKey':'E','status':1,'score':16}, {'myKey'

Solution 1:

getJSON works asynchronously and what it returns is AJAX request object. So use success callback function of getJSON to recieve the data

$.getJSON('http://d.codio.com/hugolpz/getJson--/App/data/statusStarter2.json', function(data) {
  // do JSON.stringify(data) here
});

Solution 2:

Did you try :

localStorage.setItem('data', JSON.stringify(MyJSON));

and

varJSON = localStorage.getItem('data');

and as ajax is async :

$.getJSON('url', function(MyJSON) {
     localStorage.setItem('data', JSON.stringify(MyJSON));
});

Post a Comment for "Getjson's Data : Clarification Needed"