简体   繁体   中英

Share Json between html pages

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.

You can use localStorage .

// Store
localStorage.setItem("json", JSON.stringify(json));
// Retrieve
JSON.parse(localStorage.getItem("json"));

You can use localStorage or cookie to store your json .

Read about Web-storages

But remember cookie has size limitations, read this .

您可以将json存储在.json文件中,请求可以转到这些文件并使用JSON.parse解析响应JSON.parse

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM