954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to send data in POST method using javascript

hi all,

in javascript normaly page redirection can be done as follow with a parameter.

window.location = "add-new-cos.jsp?id="+id;

but this id value is send to the next page with in the GET method. but i want to send it with the POST method.

is there any way to do it with javascript....?

thanks..
janaka priyadarshana.

rpjanaka
Junior Poster in Training
69 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

hi all,

in javascript normaly page redirection can be done as follow with a parameter.

window.location = "add-new-cos.jsp?id="+id;

but this id value is send to the next page with in the GET method. but i want to send it with the POST method.

is there any way to do it with javascript....?

thanks.. janaka priyadarshana.

Yes, there is, and it is called AJAX. Search through the AJAX forums for posting values using JS with the POST method.

Another way is to create a hidden input element, use then JS to change the hidden element value and submit the form.
e.g. something like should work, however I have not tested it. If you're familiar with JS you will figure it out.

fucntion sendByPost(hiddenField)
{
var = myvalue;
var myHiddenfield = document.getElementById(hiddenfield);
myHiddenfield.value = myvalue;
document.form.submit();
}

Good luck

Rhyan
Posting Whiz in Training
240 posts since Oct 2006
Reputation Points: 21
Solved Threads: 26
 

thanks for the idea. the second idea is the way that i wanted to know.

rpjanaka
Junior Poster in Training
69 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

IT s VERY helpful for me

vssp
Junior Poster
199 posts since Jul 2006
Reputation Points: 5
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You