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
Ok, it seems I still need help here.
var ajaxFormOptions = { beforeSerialize: function(){
$(#hidden_input).attr(value,test); } };
$('#form').ajaxForm(ajaxFormOptions);
works fine now :). However, in reality, I don't want to set the value of the
input field to an arbitrary value, I actually
but for some reason the input field stays empty this way:
Yeah, that reason is known as asynchronous programming. When you make
that ajax call you will get a response some time in the future, not
immediately.
malsup wrote:
but for some reason the input field stays empty this way:
Yeah, that reason is known as asynchronous programming. When you make
that ajax call you will get a response some time in the future, not
immediately.
Ooooh, right, I didn't think of that (I am fairly new
malsup wrote:
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);
}
};
Ooooh, right, I didn't think of that (I am fairly new to making stuff with
ajax). I guess there is no way to make the ajaxForm function wait for this
particular response? But I guess this is a different topic now..
The way to do it is to return false from the beforeSerialize function;
that
6 matches
Mail list logo