[英]Share Json between html pages
I have used jQuery AJAX got a string of JSON in the login page. 我已经使用jQuery AJAX在登录页面中获取了JSON字符串。 How can I use it in other pages.
我如何在其他页面中使用它。 Are there some method to store the JSON and access it anywhere in my website.
有什么方法可以存储JSON并在我的网站中的任何地方访问它。 ps.
ps。 I didn't use any other server script, it is only a html website.
我没有使用任何其他服务器脚本,它只是一个html网站。 The JSON string is about 5K byte.
JSON字符串约为5K字节。
You can use localStorage . 您可以使用localStorage 。
// Store
localStorage.setItem("json", JSON.stringify(json));
// Retrieve
JSON.parse(localStorage.getItem("json"));
You can use localStorage
or cookie
to store your json
. 您可以使用
localStorage
或cookie
存储您的json
。
Read about Web-storages 了解有关Web存储的信息
But remember cookie
has size limitations, read this . 但是请记住
cookie
有大小限制,请阅读此内容 。
您可以将json存储在.json
文件中,请求可以转到这些文件并使用JSON.parse
解析响应JSON.parse
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.