I have two HTML(H1, H2) pages one linked to another. I call a webservice and populate a drop down with the data response, in H1. After some operations, I move to H2. In H2, I need same data recieved in H1 from the webservice. recieved data is a large xml file.
Is there a way I can reuse the data from H1 without calling webservice again?
PS: H1 and H2 don't share any java script.
您可以使用Session
将数据存储在H1中,然后再次使用该数据在H2中。
Take a look at Jquery post and ajax functions. With them you can easily achieve what you want.
You can make use of localStorage
, sessionStorage
or cookies
.
Take a look at localStorage .
Easiest way without using jquery would be to merge the two pages into one, hide one, then display it when necessary. Simple exaple:
window.showPage = function(page) { document.getElementById(page).style.display = 'block'; page = (page - 1) * -1; // my jenky switch document.getElementById(page).style.display = 'none'; }
<div id="0"> <h1>Page 1</h1> <p>Hello, World!</p> <br> <a href="#" onclick="showPage(1)">Page 2</a> </div> <div id="1" style="display:none"> <h1>Page 2</h1> <p>Hello, Forkmohit!</p> <br> <a href="#" onclick="showPage(0)">Page 1</a> </div>
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.