0

I have a javascript function where in one part, I perform an AJAX call and store some information.

In the same function, I move to a new HTML file.

window.location.href = "deals.html";

Once moving to the new deals.html file, how can I access the information I stored earlier?

Thank you for your help.

4 Answers4

0

The information you stored using AJAX function resides in server now, you have to initiate another AJAX function to retrieve that information from the server when you get the new page.

Kemal Dağ
  • 2,743
  • 21
  • 27
0

You can write a javascript function to keep the data using cookies and access it in next page. This will be executed just befor redirecting to another page.

Ashmah
  • 842
  • 2
  • 8
  • 17
0

There is something called localStorage which is supported by latest browsers, you can use that to store response from first call, and use it second page.

Ravi Hamsa
  • 4,721
  • 3
  • 14
  • 14
0

This can only be achieved if you use cookies in JavaScript because, as you are navigating to another html document you loose the status of all the variables in the already executed script.

So before navigating away to another page set as many cookies as required.

References on cookies

Rajesh Paul
  • 6,793
  • 6
  • 40
  • 57