Search
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Codes Author
Wed, 22-Oct-2014 Authors
Zondray
40
All Time Authors
Satyapriyanayak
12160
Vishal@Neeraj
8240
Jayakumars
8120

Latest members | More ...


(Statistics delayed by 5 minutes)
 Codes

How to post to a URL with Parameters?

Shantanupatel
Posted by Shantanupatel under JavaScript on 3/9/2012 11:22:53 AM | Points: 40 | Views : 1847 | Status : [Member]

<div>

<form method="post" action="">
<input type="hidden" id="url" name="url" value="http:\\mysite"/>
<input type="hidden" id="parameter" name="parameter" value="polNo=23|seqNo=3456|status=A"/>
</form>
</div>

<script type="text/javascript" language="javascript">
$(document).ready(
function () {
postToUrl($("#url").val(), $("#parameter").val(), "post");
}
);

function postToUrl(path, params, method) {
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "parameter");
hiddenField.setAttribute("id", "parameter");
hiddenField.setAttribute("value", params);
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
}
</script>


Shantanu
Found interesting? Add this to:



Comments or Responses

Posted by: T.Saravanan on: 3/9/2012 | Level:Silver | Status: [Member] [MVP] | Points: 10

Hi,

Kindly post your code inside the code tag.

Posted by: Shantanupatel on: 3/9/2012 | Level:Starter | Status: [Member] | Points: 10

Updated!


Login to post response