Reputation: 1558
I used the ajax method of jquery for my forms. but now I need to add a field to the function.
how can I have my forms fields and my new post parameter.
var frm = $(n);
$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
//contentType:frm.attr('enctype'),
data: frm.serialize(),
success: function (data) {
$(dataform).html(data);
$(des).html('');
$("button[type='submit']").attr('disabled',null);
}
});
the data
parameter should be like this:
data: frm.serialize() + {'foo':'bar'}
thanks in advance.
Upvotes: 0
Views: 1410
Reputation: 2243
.serialize()
returns a string of parameters like you'd see in a querystring, so just add on + "&foo=bar"
Upvotes: 1