I want to send some data from one HTML page to another. I am sending the data through the query parameters like
why don't you store your values in HTML5 storage objects such as
localStorage, visit HTML5 Storage Doc to get more details. Using this you can store intermediate values temporarily/permanently locally and then access your values later.
To store values for a session:
sessionStorage.getItem('label') sessionStorage.setItem('label', 'value')
or more permanently:
localStorage.getItem('label') localStorage.setItem('label', 'value')
So you can store (temporarily) form data between multiple pages using HTML5 storage objects which you can even retain after reload..
I know this is an old post, but figured I'd share my two cents. @Neji is correct in that you can use
sessionStorage.setItem('label', 'value') (although he had the
setItem parameters backwards, not a big deal). I much more prefer the following, I think it's more succinct:
var val = sessionStorage.myValue
in place of
sessionStorage.myValue = 'value'
in place of
sessionStorage.myObject = JSON.stringify(myObject); //will set object to the stringified myObject var myObject = JSON.parse(sessionStorage.myObject); //will parse JSON string back to object
The reason is that sessionStorage stores everything as a string, so if you just say
sessionStorage.object = myObject all you get is [object Object], which doesn't help you too much.
so once when you are done retriving the data show the message and change the
window.location.hash to a suitable value.. now whenever you ll refresh the page the
hashtag wont be present
NOTE: when you will use this instead ot query strings the data being sent cannot be retrived/read by the server
But if you want to share between two pages (I assume they are not both on localhost, because that won't make sense to share between two both-backend-driven pages) you will need to specify the CORS headers to allow the browser to send data to the whitelisted domains.
These two links might help you, it shows the example via Node backend, but you get the point how it works:
And, of course, the CORS spec:
©2020 All rights reserved.