Save Javascript objects via postback

I use to add according to the data array in the table when I click the button, but when I press another button due to the postback, the whole created structure goes away, is there any way to keep this structure despite the postback?

Thanx

+3
source share
3 answers

When redirecting to another page, all values ​​that were stored in javascript variables are garbage collection and are no longer available. There are various methods for storing values ​​on the client side. One uses cookies . Another uses local HTML5 storage .

+4
source

. , - .

, , .

+1

If you need to save Javascript state through postback, then it is best to serialize your data and save it in a hidden form field with each change, and then reload this field during page reload. However, I would recommend, if possible, replacing callbacks with AJAX calls to prevent them in the first place.

+1
source

Source: https://habr.com/ru/post/1791666/


All Articles