Forum Moderators: open

Message Too Old, No Replies

can javascript POST data to a new page?

         

zRonin

2:13 pm on Jun 26, 2005 (gmt 0)

10+ Year Member



Is it possible for javascript to POST data to a new page when executed in an onChange? I know you can send a new url and include the GET parameters, but I would prefer using POST and I want to know if it is possible.

rocknbil

5:29 pm on Jun 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<form method="post" action="yourscript" onSubmit="return false;">
<select name="mySelect" onChange="=this.form.submit();">
<option value=...........
</select>
<input type="submit" value="For Non-JS support">
</form>

Like that?

RoboDada

11:55 pm on Jul 11, 2005 (gmt 0)



I have the same question, but the reply doesn't answer it.

I want to have a snippet of javascript on my page that will launch a new window in response to a button click or some other event. That new window should then display a page (from my site, in this case) but I want to pass in some 'parameters' via HTTP POST headers rather than through the URL -- so that some sensitive information is not visible to the user on an address bar.

Is this possible? Need more than a simple window.open, I'd think...

Rambo Tribble

5:10 am on Jul 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I understand the original question, I believe the answer is: POST data is sent in a header to the server. It is not available at the client, other than in its raw form.

whoisgregg

1:27 pm on Jul 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RoboDada, the way to send post data is to submit a form -- javascript can do that with in response to a mouse click or other event. rocknbil's example is exactly what you should use, with one change to POST to a new window:

<form method="post" action="yourscript" onSubmit="return false;" target="_blank">

This line is the javascript that fires the POSTing of the form:

<select name="mySelect" onChange="this.form.submit();">

But it could just as easily by fired by any other onclick, onmouseover, etc.

Trace

4:04 pm on Jul 12, 2005 (gmt 0)

10+ Year Member



An easy alternative to passing info through the URL would be to store the information in hidden files in the original page.

Then in your popup, use js to fetch the data from the hidden fields on your original page, like this :

document.write(top.opener.document.frmSomething.txtSomething.value);