Is there a way to can access and manipulate the POST params after a form submit has been made. To be more specific, in my submit event handler, how can I do something like
$("#form").submit()
{
//access the request params and manipulate them here
return true;
}
instead of the following hack which I find to be not that elegant.
$("#submit_button").click()
{
// Construct the Request 'params' manually
$.post("/foo/action", params, redirectIfSuccess);
}
You can do it before form submit. Just check the variables in the form on submit event change one or more of them and submit with new data.
With (“#myInputField”) you select the input field or you can use (“input[name=’myInputField’]”) to select a input on its name attribute.
After that you can use val() to get or val(“Some text”) to set the value of the appropriate input. That’s all.
To add new input or DOM element you have to use .append(),
Ex:
Have a look here: http://api.jquery.com/append/