How to write data in webstorage without replacing the data already recorded? [duplicate]

1

I created a form and when the user completes this form the data is sent to the local webstorage and from there to a table. However, whenever I write a data in the localstorage the previous data is overwritten, can I get the data to be sent to that table without replacing the existing data? Note: It has to be only with JQuery.

    
asked by anonymous 28.10.2016 / 02:22

1 answer

2

As already stated in other issues linked in the comments, you need to retrieve existing data and add new ones. Because web storage only accepts strings, the recommended solution is to use JSON serialization to store objects, such as arrays, in a string format, and then retrieve the object by deserializing the string.

A specific solution for your case would be to create an object that would encapsulate the required access.

28.10.2016 / 03:21