QuepasaTio QuepasaTio - 8 months ago 44
Javascript Question

Javascript get json and store locally for processing

I am looking for the best way of processing data for my charts.

At the moment, every time I need to show my charts I use ajax to get the data, then process it and finally show it on the charts.

The problem is that sometime there’s a lot of data to grab from the api so I’m thinking about getting the whole data when the page loads and storing it locally.

Then, every time I need to populate the charts I just process the data locally and there’s no extra ajax calls to make to the api.

My problem is that local storage has a maximum of 10MB and I might need more than that at some point in time.

Other than that, what are my choices here if I don’t want to use a local database?


You could use local storage:

if (typeof (Storage) !== "undefined") {
//store ajax data local
//set variable that local storage is aviable
} else {
// set variable that local storage is not aviable

Than check before processing data if you need ajax or grab localstorage.