How to post to a URL with Parameters?

Shantanupatel
Posted by Shantanupatel under JavaScript category on | Points: 40 | Views : 2468
<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>

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