Share Json between html pages

前端 未结 3 1116
别那么骄傲
别那么骄傲 2021-01-23 09:26

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. p

相关标签:
3条回答
  • 2021-01-23 10:08

    You can use localStorage.

    // Store
    localStorage.setItem("json", JSON.stringify(json));
    // Retrieve
    JSON.parse(localStorage.getItem("json"));
    
    0 讨论(0)
  • 2021-01-23 10:09

    You can use localStorage or cookie to store your json.

    Read about Web-storages

    But remember cookie has size limitations, read this.

    0 讨论(0)
  • 2021-01-23 10:29

    You can store json in .json files, and requests can go to those files and parse the responsetext with JSON.parse

    0 讨论(0)
提交回复
热议问题