Posting additional data alongside serialized form data

后端 未结 3 1066
忘了有多久
忘了有多久 2020-12-22 10:44

I want to post some additional data alongside serialized data i got from user form input.

For instance,

$.post(\'update.php\', $(\"#theform\").serial         


        
相关标签:
3条回答
  • 2020-12-22 10:55

    you can do:

    var data = $('#theform').serializeArray();
    data.push({cposition: swidget});
    //then
    $.post('update.php', data, function(data) {
    
    });
    
    0 讨论(0)
  • 2020-12-22 10:57

    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) { ... });
    
    0 讨论(0)
  • 2020-12-22 11:01

    You can append something to the end of serialized string.

    $.post('update.php', $("#theform").serialize() + '&cposition:swidget', function(data) {
    
    });
    
    0 讨论(0)
提交回复
热议问题