I have used jQuery AJAX got a string of JSON in the login page. How can I use it in other pages. Are there some method to store the JSON and access it anywhere in my website. ps. I didn't use any other server script, it is only a html website. The JSON string is about 5K byte.
Asked
Active
Viewed 1,066 times
3 Answers
5
You can use localStorage.
// Store
localStorage.setItem("json", JSON.stringify(json));
// Retrieve
JSON.parse(localStorage.getItem("json"));

Tim Green
- 3,571
- 2
- 23
- 23
-
@bohan If it solved your problem, you have to upvote and accept this answer. – Yang Feb 25 '14 at 05:04
-
1If you want just to share data between pages in the same browser session than `sessionStorage` is better choice than `localStorage` as it will not leave remnants. – c-smile Feb 25 '14 at 05:36
1
You can use localStorage
or cookie
to store your json
.
Read about Web-storages
But remember cookie
has size limitations, read this.

Community
- 1
- 1

Rohan Kumar
- 40,431
- 11
- 76
- 106
0
You can store json in .json
files, and requests can go to those files and parse the responsetext with JSON.parse

user70585
- 1,397
- 1
- 14
- 19