在html页面之间共享Json [英] Share Json between html pages

查看:108
本文介绍了在html页面之间共享Json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用jQuery AJAX在登录页面中获得了一串JSON。我如何在其他页面中使用它。是否有一些方法来存储JSON并在我的网站中的任何位置访问它。
ps。我没有使用任何其他服务器脚本,它只是一个HTML网站。 JSON字符串大约是5K字节。

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.

推荐答案

您可以使用 localStorage

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

这篇关于在html页面之间共享Json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆