Reputation: 1
When a user clicks on a button we are making an ajax call, the data came and we display the data in a div. Then user click on another button again making an ajax call and data load respective to that div, but when I click on the previous button I want that it should not make an ajax call it should pick the data from the cache. How can I do this? Please help me out on this.
Thank!!
Upvotes: 0
Views: 103
Reputation: 392
It would much clearer if you posted your code. Anyways, you can assign the old data to the previous ajax call from the second button now calling the second ajax request.
Upvotes: 0
Reputation: 552
Use localStorage, simple set the storage, and then get the storage and do a logic check.
Something like below in sudo:
localStorage.setItem("id", "stuff");
localStorage.getItem("id");
logic check
Upvotes: 1