-3

I am in sort of a pickle right now. I am trying to refresh my java page but I want to post some new data to it. But the issue is I don't know where to start. All I know is the location.reload() is there a way I can do a location reload but send new data to the refreshed paged?

Edit: Sorry I got this wrong. I have a script that always has a different url so I cant just do the new location to 'http ://...../' so I need a way I can pass values without that

arberb
  • 960
  • 3
  • 14
  • 25

2 Answers2

3

You can:

  1. use window.location.href = '/your-url?param1=value&etc=...' to send data as query string

  2. create a form with your url as the action, add fields and then submit it (this makes it possible to submit your data using POST)

Calin
  • 2,110
  • 1
  • 21
  • 36
0

Two ways are there:

1. window.location.href = 'http://www.yoursite.com?data1=val1&data2=val2';

2. window.location = 'http://www.yoursite.com?data1=val1&data2=val2';

1st method is always suggested as best practice. Refer: here

Community
  • 1
  • 1