How do I modify serialized form data in jQuery?

前端 未结 4 782
你的背包
你的背包 2020-11-30 23:14

I am trying to submit my form in AJAX, so I have to serialize() the data. But I am using fckEditor and jQuery doesn\'t know how to deal with it, so after the se

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 00:13

    With ES15 now. You can use this instead one for editing current submitted value (the shortest one)

    var values = $("#frmblog").serializeArray();
    values.find(input => input.name == 'content').value = content_val;
    console.log(values);
    

    or native function

    var values = $("#frmblog").serializeArray();
    values.find(function(input) { 
        return input.name == 'content';
    }).value = content_val;
    console.log(values);
    

提交回复
热议问题