By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,734 Members | 832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,734 IT Pros & Developers. It's quick & easy.

How to similate HTTP POST request by JavaScript?

P: n/a
How can I simulate HTTP post request by JavaScript?

When I select from <SELECT> combo box. onClick will call JavaScript
function.
I want this function to send HTTP POST request with the selected index of
the combo box.
To do this, somehow the function must simulate HTTP POST request.

Thanks in advance.
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Richard Hockey wrote on 07 jul 2003 in comp.lang.javascript:
I'm not sure you can 'simulate' a HTTP post request, but you can
submit a form using javascript to set the method, and to execute from
submission (you can also set the action and target window):

document.forms['myform'].method='post';
document.forms['myform'].action='process.php';
document.froms['myform'].target='_self';
document.forms['myform'].submit();


You are right.

It is not simulating a post http-request,

but simulating a classical HTTP-only post request.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a


reneeccwest wrote:
How can I simulate HTTP post request by JavaScript?

When I select from <SELECT> combo box. onClick will call JavaScript
function.
I want this function to send HTTP POST request with the selected index of
the combo box.
To do this, somehow the function must simulate HTTP POST request.


Why don't you use HTML?
<form action="whatever.php" method="POST">
<select name="selectName">
<option>...</option>
<option>...</option>
...
</select>
<input type="submit">
</form>

The browser will send a HTTP POST request when the submit button is
clicked/pressed without needing any script.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

P: n/a
<form name="MyForm" action="nextpage.asp" method="POST">
<select name="selectName" onChange="document.MyForm.submit">
<option>make a selection</option>
<option value = "one">one</option>
<option value = "two">two</option>
...
</select>
<input type="submit">
</form>
try something like this. Onclick is wrong because as soon as you click it
would send, without you chnaging anything.

Keep a submit button available for non JS users.

Does that help? If not, let us see some code and tell us exactly what you
want it to do.

Stu
"reneeccwest" <re*********@hotmail.com> wrote in message
news:9f**************************@posting.google.c om...
How can I simulate HTTP post request by JavaScript?

When I select from <SELECT> combo box. onClick will call JavaScript
function.
I want this function to send HTTP POST request with the selected index of
the combo box.
To do this, somehow the function must simulate HTTP POST request.

Thanks in advance.

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.