Is there a way to use javascript and JQuery to add some additional fields to be sent from a HTTP form using POST?
I mean:
<form action="somewhere" method="POST" id="form"> <input type="submit" name="submit" value="Send" /> </form> <script type="text/javascript"> $("#form").submit( function(eventObj) { // I want to add a field "field" with value "value" here // to the POST data return true; }); </script>
Yes.You can try with some hidden params.
$("#form").submit( function(eventObj) { $("<input />").attr("type", "hidden") .attr("name", "something") .attr("value", "something") .appendTo("#form"); return true; });
2.1m questions
2.1m answers
60 comments
57.0k users