Reputation: 13683
I want to post some additional data alongside serialized data i got from user form input.
For instance,
$.post('update.php', $("#theform").serialize(),{cposition:swidget}, function(data) {
});
This does not post the additional post.How am i supposed to post the additional data?.
Upvotes: 0
Views: 228
Reputation: 66490
You can append something to the end of serialized string.
$.post('update.php', $("#theform").serialize() + '&cposition:swidget', function(data) {
});
Upvotes: 1
Reputation: 129792
The jQuery serialize
function yields its values in the &key=value
format. It does this using $.param
internally. You would be able to append your own values in the same manner:
$.post('update.php', [$('#theform').serialize(), $.param({cposition:swidget})].join('&'), function(data) { ... });
Upvotes: 1
Reputation: 100175
you can do:
var data = $('#theform').serializeArray();
data.push({cposition: swidget});
//then
$.post('update.php', data, function(data) {
});
Upvotes: 1