Hi i\'m a beginner in JavaScript i would like to ask if its possible to session the data i\'m getting from a server. The data i want to session is the \'data.xhr.response\' i se
Session storage is same as local storage but the only difference is that data stored in session storage will clear automatically once page session will expire.
Now come to your question. In your success
function, do like below to store data:
success : function(data) {
console.log(data.xhr.response);
sessionStorage.setItem('dataStored', data.xhr.response);
}
Usage is like below:
// Save data to sessionStorage
sessionStorage.setItem('dataStored', data.xhr.response);
// Get saved data from sessionStorage
var data = sessionStorage.getItem('dataStored');
// Remove saved data from sessionStorage
sessionStorage.removeItem('dataStored');
// Remove all saved data from sessionStorage
sessionStorage.clear();
For more information about sessionStorage
check this link : https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage