> I am using the jQuery Form Plugin to submit a form via AJAX. One thing I'd
> like to do, is editing the value of a (hidden) input field, right before the
> form is sent (or alternatively adding additional POST data in some way
> before send). I defined a hidden input field (without a value) in the form
> and I tried to change the "value" attribute with jQuery in the "beforeSend"
> section of the ajaxForm Options. Unfortunately this doesn't work, the field
> still stays empty.

This sort of thing comes up a lot so I've added a new callback
function called 'beforeSerialize'.  You can use it like this:

var ajaxFormOptions = {
    beforeSerialize: function($form, opts) {
        $("#hidden_input").attr("value","test");
    }
};

$('#form').ajaxForm(ajaxFormOptions);


The updated plugin is available here:

http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js

Reply via email to